fix FLAC playback over non-ideal HTTP streams

git-svn-id: https://svn.musicpd.org/mpd/trunk@3076 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong 2005-03-13 22:58:04 +00:00
parent 92f1bb82f7
commit 5bddf6eefc

View File

@ -196,10 +196,20 @@ FLAC__SeekableStreamDecoderReadStatus flacRead(
const FLAC__SeekableStreamDecoder * flacDec, FLAC__byte buf[],
unsigned * bytes, void * fdata) {
FlacData * data = (FlacData *) fdata;
size_t r;
*bytes = readFromInputStream(data->inStream,(void *)buf,1,*bytes);
if(*bytes==0) return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
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;
}