Hi all,

when I try to play a WAV file streamed by a media server I get a corrupted 
playback. The same file, retrieved with "curl -o … http://…"; and played as a 
local file works flawlessly.

Further investigations show that it is due to a bad interaction between the 
CurlInputPlugin and the libsndfile library used to decode the stream.

The problem itself is very simple: libsndfile needs that the read function in 
CurlInputPlugin return a number of bytes that is a multiple of the frames size 
of the WAV file being decoded (4, 6 or 8 bytes for 16, 24, 32 bit depth, 
respectively, for a 2 channel PCM stream). If the read function doesn’t return 
whole frames, libsndfile discards the last “remaining” bytes of the returned 
buffer and the corruption occurs.

So the different behavior between the http stream and the local file is easily 
explained: CurlInputPlugin doesn’t always return the requested number of bytes 
whereas FileInputPlugin always returns the requested number of bytes, making 
libsndfile happy.

I tried to think to several solutions, but as long as the whole read functions 
chain doesn’t include a “nbr of items” parameter, the only viable solution 
seems to be CurlInputPlugin block until the request number of bytes can be 
returned to the caller (or EOF is reached).

Any comment?

Marcello
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to