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.
This commit is contained in:
parent
ea51f73285
commit
0d45870cea
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user