From 5bddf6eefcc9c1d0245d8e86cd77ed6dddb5d406 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 Mar 2005 22:58:04 +0000 Subject: fix FLAC playback over non-ideal HTTP streams git-svn-id: https://svn.musicpd.org/mpd/trunk@3076 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/inputPlugins/flac_plugin.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 9c20a996d..801b72797 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -196,10 +196,20 @@ FLAC__SeekableStreamDecoderReadStatus flacRead( const FLAC__SeekableStreamDecoder * flacDec, FLAC__byte buf[], unsigned * bytes, void * fdata) { FlacData * data = (FlacData *) fdata; - - *bytes = readFromInputStream(data->inStream,(void *)buf,1,*bytes); - - if(*bytes==0) return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; + size_t r; + + while (1) { + r = readFromInputStream(data->inStream,(void *)buf,1,*bytes); + if (r == 0 && !inputStreamAtEOF(data->inStream) && + !data->dc->stop) + my_usleep(10000); + else + break; + } + *bytes = r; + + if (*bytes==0 && !inputStreamAtEOF(data->inStream) && !data->dc->stop) + return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; } -- cgit v1.2.3