From 940ecf5345f339b9d3ec3e8029e345540358fa4c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:14 +0200 Subject: added decoder_read() On our way to stabilize the decoder API, we will one day remove the input stream functions. The most basic function, read() will be provided by decoder_api.h with this patch. It already contains a loop (still with manual polling), error/eof handling and decoder command checks. This kind of code used to be duplicated in all decoder plugins. --- src/inputPlugins/mp3_plugin.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/inputPlugins/mp3_plugin.c') diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index c2bac068d..aaf5ae55a 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -233,15 +233,10 @@ static int fillMp3InputBuffer(mp3DecodeData * data) if (readSize == 0) return -1; - readed = readFromInputStream(data->inStream, readStart, (size_t) 1, - readSize); - if (readed <= 0 && inputStreamAtEOF(data->inStream)) + readed = decoder_read(data->decoder, data->inStream, + readStart, readSize); + if (readed == 0) return -1; - /* sleep for a fraction of a second! */ - else if (readed <= 0) { - readed = 0; - my_usleep(10000); - } mad_stream_buffer(&data->stream, data->readBuffer, readed + remaining); (data->stream).error = 0; @@ -324,13 +319,10 @@ static void mp3_parseId3Tag(mp3DecodeData * data, size_t tagsize, while (count < tagsize) { size_t len; - len = readFromInputStream(data->inStream, - allocated + count, (size_t) 1, - tagsize - count); - if (len <= 0 && inputStreamAtEOF(data->inStream)) { + len = decoder_read(data->decoder, data->inStream, + allocated + count, tagsize - count); + if (len == 0) break; - } else if (len <= 0) - my_usleep(10000); else count += len; } -- cgit v1.2.3