From 0d45870cea6836cd48e6953f4e67756b2502e22c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:05 +0200 Subject: 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. --- src/inputPlugins/aac_plugin.c | 2 +- src/inputPlugins/audiofile_plugin.c | 4 ++-- src/inputPlugins/flac_plugin.c | 4 ++-- src/inputPlugins/mod_plugin.c | 2 +- src/inputPlugins/mp3_plugin.c | 8 ++++---- src/inputPlugins/mp4_plugin.c | 6 +++--- src/inputPlugins/mpc_plugin.c | 4 ++-- src/inputPlugins/oggflac_plugin.c | 5 ++--- src/inputPlugins/oggvorbis_plugin.c | 4 ++-- src/inputPlugins/wavpack_plugin.c | 4 ++-- 10 files changed, 21 insertions(+), 22 deletions(-) (limited to 'src/inputPlugins') 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) -- cgit v1.2.3