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/decoder_api.c                   |   10 ++++++++++
 src/decoder_api.h                   |    4 ++++
 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 ++--
 12 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/src/decoder_api.c b/src/decoder_api.c
index 681f593..99f7293 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 a56b7ef..a4fd7fc 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 c6bd998..8765dc2 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 fc25726..696621a 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 43be1a2..4bfc872 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 792cb0c..930b041 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 399491d..9959f86 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 197d006..f917ec3 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 abdf44c..13f2adc 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 91b4de4..b5e73e4 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 1333bc1..9e1cf89 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 e4134bb..9d125f0 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)


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to