Il giorno 20/gen/2014, alle ore 17:51, Max Kellermann <[email protected]> ha scritto:
> On 2014/01/19 13:14, Marcello Desantis <[email protected]> wrote: >> 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. > [...] >> 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. > > Thanks for debugging. Though it would be preferrable to use the bug tracker. I wrote here because I was not sure it was an MPD bug and I still think is is not. If libsndfile needs whole frames, it should define a vio_read interface with item_size and number_of_items. Forcing the vio_read implementation to always return the requested buffer length is not as streaming friendly as it should be. > >> 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). > > No, not a good idea. Some callers may pass very large buffers, and > blocking until the buffer is full would make MPD stutter (ALSA > underrun), because that would increase latency a lot. > > We should never make all InputStream callers suffer because of some > undocumented (and stupid) libsndfile API requirement. What we can do > instead is implement this only in sndfile_vio_read(). You’re right, of course. The plugin implementation is, by design, the place dedicated to dealing with the underlying library requirements. > > Max Marcello _______________________________________________ mpd-devel mailing list [email protected] http://mailman.blarg.de/listinfo/mpd-devel
