aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}