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;
|
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,
|
float data_time, mpd_uint16 bitRate,
|
||||||
ReplayGainInfo * replayGainInfo);
|
ReplayGainInfo * replayGainInfo);
|
||||||
|
|
||||||
|
void decoder_flush(struct decoder *decoder);
|
||||||
|
|
||||||
|
void decoder_clear(struct decoder *decoder);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -403,7 +403,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_flush();
|
decoder_flush(mpd_decoder);
|
||||||
|
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
if (b.buffer)
|
if (b.buffer)
|
||||||
|
@ -92,7 +92,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
|
|
||||||
while (!eof) {
|
while (!eof) {
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
current = dc.seekWhere *
|
current = dc.seekWhere *
|
||||||
dc.audioFormat.sampleRate;
|
dc.audioFormat.sampleRate;
|
||||||
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
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);
|
afCloseFile(af_fp);
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ static int flac_decode_internal(struct decoder * decoder,
|
|||||||
FLAC__uint64 sampleToSeek = dc.seekWhere *
|
FLAC__uint64 sampleToSeek = dc.seekWhere *
|
||||||
dc.audioFormat.sampleRate + 0.5;
|
dc.audioFormat.sampleRate + 0.5;
|
||||||
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
dc.audioFormat.sampleRate;
|
dc.audioFormat.sampleRate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
@ -442,7 +442,7 @@ static int flac_decode_internal(struct decoder * decoder,
|
|||||||
/* send last little bit */
|
/* send last little bit */
|
||||||
if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
|
if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
|
||||||
flacSendChunk(&data);
|
flacSendChunk(&data);
|
||||||
ob_flush();
|
decoder_flush(decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -205,7 +205,7 @@ static int mod_decode(struct decoder * decoder, char *path)
|
|||||||
total_time, 0, NULL);
|
total_time, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_flush();
|
decoder_flush(decoder);
|
||||||
|
|
||||||
mod_close(data);
|
mod_close(data);
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
|
|||||||
case MUTEFRAME_SEEK:
|
case MUTEFRAME_SEEK:
|
||||||
if (dc.seekWhere <= data->elapsedTime) {
|
if (dc.seekWhere <= data->elapsedTime) {
|
||||||
data->outputPtr = data->outputBuffer;
|
data->outputPtr = data->outputBuffer;
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
data->muteFrame = 0;
|
data->muteFrame = 0;
|
||||||
dc_command_finished();
|
dc_command_finished();
|
||||||
}
|
}
|
||||||
@ -963,7 +963,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
|
|||||||
data->frameOffset[j]) ==
|
data->frameOffset[j]) ==
|
||||||
0) {
|
0) {
|
||||||
data->outputPtr = data->outputBuffer;
|
data->outputPtr = data->outputBuffer;
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
data->currentFrame = j;
|
data->currentFrame = j;
|
||||||
} else
|
} else
|
||||||
dc.seekError = 1;
|
dc.seekError = 1;
|
||||||
@ -1081,11 +1081,11 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
|
|
||||||
if (dc.command == DECODE_COMMAND_SEEK &&
|
if (dc.command == DECODE_COMMAND_SEEK &&
|
||||||
data.muteFrame == MUTEFRAME_SEEK) {
|
data.muteFrame == MUTEFRAME_SEEK) {
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
dc_command_finished();
|
dc_command_finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_flush();
|
decoder_flush(decoder);
|
||||||
mp3DecodeDataFinalize(&data);
|
mp3DecodeDataFinalize(&data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -211,7 +211,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
|
|
||||||
if (seeking && seekPositionFound) {
|
if (seeking && seekPositionFound) {
|
||||||
seekPositionFound = 0;
|
seekPositionFound = 0;
|
||||||
ob_clear();
|
decoder_clear(mpd_decoder);
|
||||||
seeking = 0;
|
seeking = 0;
|
||||||
dc_command_finished();
|
dc_command_finished();
|
||||||
}
|
}
|
||||||
@ -288,10 +288,10 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (dc.command == DECODE_COMMAND_SEEK && seeking) {
|
if (dc.command == DECODE_COMMAND_SEEK && seeking) {
|
||||||
ob_clear();
|
decoder_clear(mpd_decoder);
|
||||||
dc_command_finished();
|
dc_command_finished();
|
||||||
}
|
}
|
||||||
ob_flush();
|
decoder_flush(mpd_decoder);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
samplePos = dc.seekWhere * dc.audioFormat.sampleRate;
|
samplePos = dc.seekWhere * dc.audioFormat.sampleRate;
|
||||||
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
||||||
ob_clear();
|
decoder_clear(mpd_decoder);
|
||||||
s16 = (mpd_sint16 *) chunk;
|
s16 = (mpd_sint16 *) chunk;
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
} else
|
} else
|
||||||
@ -242,7 +242,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
replayGainInfo);
|
replayGainInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_flush();
|
decoder_flush(mpd_decoder);
|
||||||
|
|
||||||
freeReplayGainInfo(replayGainInfo);
|
freeReplayGainInfo(replayGainInfo);
|
||||||
|
|
||||||
|
@ -334,7 +334,6 @@ static unsigned int oggflac_try_decode(InputStream * inStream)
|
|||||||
static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||||
{
|
{
|
||||||
DecoderControl *dc = mpd_decoder->dc;
|
DecoderControl *dc = mpd_decoder->dc;
|
||||||
OutputBuffer *ob = mpd_decoder->ob;
|
|
||||||
OggFLAC__SeekableStreamDecoder *decoder = NULL;
|
OggFLAC__SeekableStreamDecoder *decoder = NULL;
|
||||||
FlacData data;
|
FlacData data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -359,7 +358,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
dc.audioFormat.sampleRate + 0.5;
|
dc.audioFormat.sampleRate + 0.5;
|
||||||
if (OggFLAC__seekable_stream_decoder_seek_absolute
|
if (OggFLAC__seekable_stream_decoder_seek_absolute
|
||||||
(decoder, sampleToSeek)) {
|
(decoder, sampleToSeek)) {
|
||||||
ob_clear();
|
decoder_clear(mpd_decoder);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
dc.audioFormat.sampleRate;
|
dc.audioFormat.sampleRate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
@ -377,7 +376,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
/* send last little bit */
|
/* send last little bit */
|
||||||
if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
|
if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
|
||||||
flacSendChunk(&data);
|
flacSendChunk(&data);
|
||||||
ob_flush();
|
decoder_flush(mpd_decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -269,7 +269,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
while (1) {
|
while (1) {
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
if (0 == ov_time_seek_page(&vf, dc.seekWhere)) {
|
if (0 == ov_time_seek_page(&vf, dc.seekWhere)) {
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
} else
|
} else
|
||||||
dc.seekError = 1;
|
dc.seekError = 1;
|
||||||
@ -332,7 +332,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
|
|
||||||
ov_clear(&vf);
|
ov_clear(&vf);
|
||||||
|
|
||||||
ob_flush();
|
decoder_flush(decoder);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
if (canseek) {
|
if (canseek) {
|
||||||
int where;
|
int where;
|
||||||
|
|
||||||
ob_clear();
|
decoder_clear(decoder);
|
||||||
|
|
||||||
where = dc.seekWhere *
|
where = dc.seekWhere *
|
||||||
dc.audioFormat.sampleRate;
|
dc.audioFormat.sampleRate;
|
||||||
@ -214,7 +214,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
}
|
}
|
||||||
} while (samplesgot == samplesreq);
|
} while (samplesgot == samplesreq);
|
||||||
|
|
||||||
ob_flush();
|
decoder_flush(decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *wavpack_tag(WavpackContext *wpc, char *key)
|
static char *wavpack_tag(WavpackContext *wpc, char *key)
|
||||||
|
Loading…
Reference in New Issue
Block a user