diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:05 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:05 +0200 |
commit | 0d45870cea6836cd48e6953f4e67756b2502e22c (patch) | |
tree | b869b8bdab13374f21347bd77a32661ddcf74b88 | |
parent | ea51f73285f4aca931c8c7f497838da573f89142 (diff) | |
download | mpd-0d45870cea6836cd48e6953f4e67756b2502e22c.tar.gz mpd-0d45870cea6836cd48e6953f4e67756b2502e22c.tar.xz mpd-0d45870cea6836cd48e6953f4e67756b2502e22c.zip |
added decoder_clear() and decoder_flush()
We are now beginning to remove direct structure accesses from the
decoder plugins. decoder_clear() and decoder_flush() mask two very
common buffer functions.
-rw-r--r-- | src/decoder_api.c | 10 | ||||
-rw-r--r-- | src/decoder_api.h | 4 | ||||
-rw-r--r-- | src/inputPlugins/aac_plugin.c | 2 | ||||
-rw-r--r-- | src/inputPlugins/audiofile_plugin.c | 4 | ||||
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 4 | ||||
-rw-r--r-- | src/inputPlugins/mod_plugin.c | 2 | ||||
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 8 | ||||
-rw-r--r-- | src/inputPlugins/mp4_plugin.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/mpc_plugin.c | 4 | ||||
-rw-r--r-- | src/inputPlugins/oggflac_plugin.c | 5 | ||||
-rw-r--r-- | src/inputPlugins/oggvorbis_plugin.c | 4 | ||||
-rw-r--r-- | src/inputPlugins/wavpack_plugin.c | 4 |
12 files changed, 35 insertions, 22 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c index 681f593f8..99f7293bb 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -109,3 +109,13 @@ int decoder_data(mpd_unused struct decoder *decoder, InputStream * inStream, return 0; } + +void decoder_flush(mpd_unused struct decoder *decoder) +{ + ob_flush(); +} + +void decoder_clear(mpd_unused struct decoder *decoder) +{ + ob_clear(); +} diff --git a/src/decoder_api.h b/src/decoder_api.h index a56b7ef55..a4fd7fc97 100644 --- a/src/decoder_api.h +++ b/src/decoder_api.h @@ -55,4 +55,8 @@ int decoder_data(struct decoder *decoder, InputStream * inStream, float data_time, mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo); +void decoder_flush(struct decoder *decoder); + +void decoder_clear(struct decoder *decoder); + #endif diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c index c6bd99850..8765dc21c 100644 --- a/src/inputPlugins/aac_plugin.c +++ b/src/inputPlugins/aac_plugin.c @@ -403,7 +403,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path) } } - ob_flush(); + decoder_flush(mpd_decoder); faacDecClose(decoder); if (b.buffer) diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c index fc257263e..696621aff 100644 --- a/src/inputPlugins/audiofile_plugin.c +++ b/src/inputPlugins/audiofile_plugin.c @@ -92,7 +92,7 @@ static int audiofile_decode(struct decoder * decoder, char *path) while (!eof) { if (dc.command == DECODE_COMMAND_SEEK) { - ob_clear(); + decoder_clear(decoder); current = dc.seekWhere * dc.audioFormat.sampleRate; afSeekFrame(af_fp, AF_DEFAULT_TRACK, current); @@ -118,7 +118,7 @@ static int audiofile_decode(struct decoder * decoder, char *path) } } - ob_flush(); + decoder_flush(decoder); } afCloseFile(af_fp); diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 43be1a2b9..4bfc87246 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -426,7 +426,7 @@ static int flac_decode_internal(struct decoder * decoder, FLAC__uint64 sampleToSeek = dc.seekWhere * dc.audioFormat.sampleRate + 0.5; if (flac_seek_absolute(flacDec, sampleToSeek)) { - ob_clear(); + decoder_clear(decoder); data.time = ((float)sampleToSeek) / dc.audioFormat.sampleRate; data.position = 0; @@ -442,7 +442,7 @@ static int flac_decode_internal(struct decoder * decoder, /* send last little bit */ if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) { flacSendChunk(&data); - ob_flush(); + decoder_flush(decoder); } fail: diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c index 792cb0c87..930b041e9 100644 --- a/src/inputPlugins/mod_plugin.c +++ b/src/inputPlugins/mod_plugin.c @@ -205,7 +205,7 @@ static int mod_decode(struct decoder * decoder, char *path) total_time, 0, NULL); } - ob_flush(); + decoder_flush(decoder); mod_close(data); diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 399491d0e..9959f8601 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -853,7 +853,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, case MUTEFRAME_SEEK: if (dc.seekWhere <= data->elapsedTime) { data->outputPtr = data->outputBuffer; - ob_clear(); + decoder_clear(decoder); data->muteFrame = 0; dc_command_finished(); } @@ -963,7 +963,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, data->frameOffset[j]) == 0) { data->outputPtr = data->outputBuffer; - ob_clear(); + decoder_clear(decoder); data->currentFrame = j; } else dc.seekError = 1; @@ -1081,11 +1081,11 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream) if (dc.command == DECODE_COMMAND_SEEK && data.muteFrame == MUTEFRAME_SEEK) { - ob_clear(); + decoder_clear(decoder); dc_command_finished(); } - ob_flush(); + decoder_flush(decoder); mp3DecodeDataFinalize(&data); return 0; diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c index 197d00627..f917ec345 100644 --- a/src/inputPlugins/mp4_plugin.c +++ b/src/inputPlugins/mp4_plugin.c @@ -211,7 +211,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) if (seeking && seekPositionFound) { seekPositionFound = 0; - ob_clear(); + decoder_clear(mpd_decoder); seeking = 0; dc_command_finished(); } @@ -288,10 +288,10 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) return -1; if (dc.command == DECODE_COMMAND_SEEK && seeking) { - ob_clear(); + decoder_clear(mpd_decoder); dc_command_finished(); } - ob_flush(); + decoder_flush(mpd_decoder); return 0; } diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index abdf44c63..13f2adcee 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -179,7 +179,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream) if (dc.command == DECODE_COMMAND_SEEK) { samplePos = dc.seekWhere * dc.audioFormat.sampleRate; if (mpc_decoder_seek_sample(&decoder, samplePos)) { - ob_clear(); + decoder_clear(mpd_decoder); s16 = (mpd_sint16 *) chunk; chunkpos = 0; } else @@ -242,7 +242,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream) replayGainInfo); } - ob_flush(); + decoder_flush(mpd_decoder); freeReplayGainInfo(replayGainInfo); diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index 91b4de435..b5e73e455 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -334,7 +334,6 @@ static unsigned int oggflac_try_decode(InputStream * inStream) static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream) { DecoderControl *dc = mpd_decoder->dc; - OutputBuffer *ob = mpd_decoder->ob; OggFLAC__SeekableStreamDecoder *decoder = NULL; FlacData data; int ret = 0; @@ -359,7 +358,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream) dc.audioFormat.sampleRate + 0.5; if (OggFLAC__seekable_stream_decoder_seek_absolute (decoder, sampleToSeek)) { - ob_clear(); + decoder_clear(mpd_decoder); data.time = ((float)sampleToSeek) / dc.audioFormat.sampleRate; data.position = 0; @@ -377,7 +376,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream) /* send last little bit */ if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) { flacSendChunk(&data); - ob_flush(); + decoder_flush(mpd_decoder); } fail: diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index 1333bc15c..9e1cf89c0 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -269,7 +269,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) while (1) { if (dc.command == DECODE_COMMAND_SEEK) { if (0 == ov_time_seek_page(&vf, dc.seekWhere)) { - ob_clear(); + decoder_clear(decoder); chunkpos = 0; } else dc.seekError = 1; @@ -332,7 +332,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) ov_clear(&vf); - ob_flush(); + decoder_flush(decoder); return 0; } diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c index e4134bb31..9d125f053 100644 --- a/src/inputPlugins/wavpack_plugin.c +++ b/src/inputPlugins/wavpack_plugin.c @@ -177,7 +177,7 @@ static void wavpack_decode(struct decoder * decoder, if (canseek) { int where; - ob_clear(); + decoder_clear(decoder); where = dc.seekWhere * dc.audioFormat.sampleRate; @@ -214,7 +214,7 @@ static void wavpack_decode(struct decoder * decoder, } } while (samplesgot == samplesreq); - ob_flush(); + decoder_flush(decoder); } static char *wavpack_tag(WavpackContext *wpc, char *key) |