decoder_api: removed decoder_clear()
Call ob_clear() in decoder_command_finished() instead of implementing that call in every decoder plugin.
This commit is contained in:
parent
d6c4441c78
commit
be90199c5a
@ -92,7 +92,6 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
||||||
decoder_clear(decoder);
|
|
||||||
current = decoder_seek_where(decoder) *
|
current = decoder_seek_where(decoder) *
|
||||||
audio_format.sample_rate;
|
audio_format.sample_rate;
|
||||||
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
||||||
|
@ -271,7 +271,6 @@ static int ffmpeg_decode_internal(BasePtrs *base)
|
|||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
||||||
|
|
||||||
DEBUG("seek\n");
|
DEBUG("seek\n");
|
||||||
decoder_clear(decoder);
|
|
||||||
current = decoder_seek_where(decoder) * AV_TIME_BASE;
|
current = decoder_seek_where(decoder) * AV_TIME_BASE;
|
||||||
|
|
||||||
if (av_seek_frame(pFormatCtx, -1, current , 0) < 0) {
|
if (av_seek_frame(pFormatCtx, -1, current , 0) < 0) {
|
||||||
|
@ -349,7 +349,6 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
|
|||||||
FLAC__uint64 sampleToSeek = decoder_seek_where(decoder) *
|
FLAC__uint64 sampleToSeek = decoder_seek_where(decoder) *
|
||||||
data.audio_format.sample_rate + 0.5;
|
data.audio_format.sample_rate + 0.5;
|
||||||
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
||||||
decoder_clear(decoder);
|
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
data.audio_format.sample_rate;
|
data.audio_format.sample_rate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
|
@ -1018,7 +1018,6 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
|
|||||||
decoder_seek_where(decoder));
|
decoder_seek_where(decoder));
|
||||||
if (j < data->highest_frame) {
|
if (j < data->highest_frame) {
|
||||||
if (mp3_seek(data, data->frame_offsets[j])) {
|
if (mp3_seek(data, data->frame_offsets[j])) {
|
||||||
decoder_clear(decoder);
|
|
||||||
data->current_frame = j;
|
data->current_frame = j;
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
} else
|
} else
|
||||||
@ -1026,7 +1025,6 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
|
|||||||
} else {
|
} else {
|
||||||
data->seek_where = decoder_seek_where(decoder);
|
data->seek_where = decoder_seek_where(decoder);
|
||||||
data->mute_frame = MUTEFRAME_SEEK;
|
data->mute_frame = MUTEFRAME_SEEK;
|
||||||
decoder_clear(decoder);
|
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1130,10 +1128,8 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
|||||||
freeReplayGainInfo(replay_gain_info);
|
freeReplayGainInfo(replay_gain_info);
|
||||||
|
|
||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
|
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
|
||||||
data.mute_frame == MUTEFRAME_SEEK) {
|
data.mute_frame == MUTEFRAME_SEEK)
|
||||||
decoder_clear(decoder);
|
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
}
|
|
||||||
|
|
||||||
decoder_flush(decoder);
|
decoder_flush(decoder);
|
||||||
mp3_data_finish(&data);
|
mp3_data_finish(&data);
|
||||||
|
@ -224,7 +224,6 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
|
|
||||||
if (seeking && seekPositionFound) {
|
if (seeking && seekPositionFound) {
|
||||||
seekPositionFound = false;
|
seekPositionFound = false;
|
||||||
decoder_clear(mpd_decoder);
|
|
||||||
seeking = 0;
|
seeking = 0;
|
||||||
decoder_command_finished(mpd_decoder);
|
decoder_command_finished(mpd_decoder);
|
||||||
}
|
}
|
||||||
@ -296,10 +295,9 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking) {
|
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking)
|
||||||
decoder_clear(mpd_decoder);
|
|
||||||
decoder_command_finished(mpd_decoder);
|
decoder_command_finished(mpd_decoder);
|
||||||
}
|
|
||||||
decoder_flush(mpd_decoder);
|
decoder_flush(mpd_decoder);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -168,7 +168,6 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
samplePos = decoder_seek_where(mpd_decoder) *
|
samplePos = decoder_seek_where(mpd_decoder) *
|
||||||
audio_format.sample_rate;
|
audio_format.sample_rate;
|
||||||
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
||||||
decoder_clear(mpd_decoder);
|
|
||||||
s16 = (int16_t *) chunk;
|
s16 = (int16_t *) chunk;
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
decoder_command_finished(mpd_decoder);
|
decoder_command_finished(mpd_decoder);
|
||||||
|
@ -261,7 +261,6 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
|||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
||||||
double seek_where = decoder_seek_where(decoder);
|
double seek_where = decoder_seek_where(decoder);
|
||||||
if (0 == ov_time_seek_page(&vf, seek_where)) {
|
if (0 == ov_time_seek_page(&vf, seek_where)) {
|
||||||
decoder_clear(decoder);
|
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
} else
|
} else
|
||||||
|
@ -174,8 +174,6 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
if (canseek) {
|
if (canseek) {
|
||||||
int where;
|
int where;
|
||||||
|
|
||||||
decoder_clear(decoder);
|
|
||||||
|
|
||||||
where = decoder_seek_where(decoder) *
|
where = decoder_seek_where(decoder) *
|
||||||
audio_format.sample_rate;
|
audio_format.sample_rate;
|
||||||
if (WavpackSeekSample(wpc, where)) {
|
if (WavpackSeekSample(wpc, where)) {
|
||||||
|
@ -77,6 +77,10 @@ void decoder_command_finished(mpd_unused struct decoder * decoder)
|
|||||||
assert(dc.command != DECODE_COMMAND_SEEK ||
|
assert(dc.command != DECODE_COMMAND_SEEK ||
|
||||||
dc.seekError || decoder->seeking);
|
dc.seekError || decoder->seeking);
|
||||||
|
|
||||||
|
if (dc.command == DECODE_COMMAND_SEEK)
|
||||||
|
/* delete frames from the old song position */
|
||||||
|
ob_clear();
|
||||||
|
|
||||||
dc.command = DECODE_COMMAND_NONE;
|
dc.command = DECODE_COMMAND_NONE;
|
||||||
notify_signal(&pc.notify);
|
notify_signal(&pc.notify);
|
||||||
}
|
}
|
||||||
@ -209,8 +213,3 @@ void decoder_flush(mpd_unused struct decoder *decoder)
|
|||||||
{
|
{
|
||||||
ob_flush();
|
ob_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void decoder_clear(mpd_unused struct decoder *decoder)
|
|
||||||
{
|
|
||||||
ob_clear();
|
|
||||||
}
|
|
||||||
|
@ -161,6 +161,4 @@ decoder_data(struct decoder *decoder,
|
|||||||
|
|
||||||
void decoder_flush(struct decoder *decoder);
|
void decoder_flush(struct decoder *decoder);
|
||||||
|
|
||||||
void decoder_clear(struct decoder *decoder);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user