aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/mp3_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:14 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:14 +0200
commit940ecf5345f339b9d3ec3e8029e345540358fa4c (patch)
treebe22d8c04732d41f1ba6f49298eef7829d097095 /src/inputPlugins/mp3_plugin.c
parentd80260ab4e1d4f926344ab2074543ea4a7723216 (diff)
downloadmpd-940ecf5345f339b9d3ec3e8029e345540358fa4c.tar.gz
mpd-940ecf5345f339b9d3ec3e8029e345540358fa4c.tar.xz
mpd-940ecf5345f339b9d3ec3e8029e345540358fa4c.zip
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.
Diffstat (limited to 'src/inputPlugins/mp3_plugin.c')
-rw-r--r--src/inputPlugins/mp3_plugin.c20
1 files changed, 6 insertions, 14 deletions
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;
}