aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2005-03-13 22:58:04 +0000
committerEric Wong <normalperson@yhbt.net>2005-03-13 22:58:04 +0000
commit5bddf6eefcc9c1d0245d8e86cd77ed6dddb5d406 (patch)
treecec3d30e9c2f6994c3d460e6e904e280bc4f3e01 /src
parent92f1bb82f7d9b7df73f4f3e09abc97d5fe8e229c (diff)
downloadmpd-5bddf6eefcc9c1d0245d8e86cd77ed6dddb5d406.tar.gz
mpd-5bddf6eefcc9c1d0245d8e86cd77ed6dddb5d406.tar.xz
mpd-5bddf6eefcc9c1d0245d8e86cd77ed6dddb5d406.zip
fix FLAC playback over non-ideal HTTP streams
git-svn-id: https://svn.musicpd.org/mpd/trunk@3076 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/inputPlugins/flac_plugin.c18
1 files changed, 14 insertions, 4 deletions
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;
}