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/oggvorbis_plugin.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/inputPlugins/oggvorbis_plugin.c') diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index 4801cb47..6a6ecbd9 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -58,18 +58,12 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata) size_t ret; OggCallbackData *data = (OggCallbackData *) vdata; - while (1) { - ret = readFromInputStream(data->inStream, ptr, size, nmemb); - if (ret == 0 && !inputStreamAtEOF(data->inStream) && - decoder_get_command(data->decoder) != DECODE_COMMAND_STOP) { - my_usleep(10000); - } else - break; - } + ret = decoder_read(data->decoder, data->inStream, ptr, size * nmemb); + errno = 0; /*if(ret<0) errno = ((InputStream *)inStream)->error; */ - return ret; + return ret / size; } static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence) -- cgit v1.2.3