diff options
author | Max Kellermann <max@duempel.org> | 2008-10-29 17:22:56 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-29 17:22:56 +0100 |
commit | d6c4441c785d5ae41feba865727fd7ecdfbad361 (patch) | |
tree | 76a8d27e4d123151f836a7e794ada894efcaea74 /src | |
parent | de588448df1c5d9953914a4f217e0e5d0cba80d3 (diff) | |
download | mpd-d6c4441c785d5ae41feba865727fd7ecdfbad361.tar.gz mpd-d6c4441c785d5ae41feba865727fd7ecdfbad361.tar.xz mpd-d6c4441c785d5ae41feba865727fd7ecdfbad361.zip |
mp3: seek in background
Remember the seek_where argument and call decoder_command_finished()
immediately. This way, the player thread can continue working, and we
can receive more commands.
This also fixes several issues which resulted in broken frames,
leading to erroneos "elapsed" values: frames weren't parsed properly,
since the code was checking for command!=NONE.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/mp3_plugin.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index 0f9376b10..d001efbda 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -110,6 +110,7 @@ struct mp3_data { int32_t output_buffer[MP3_DATA_OUTPUT_BUFFER_SIZE]; float total_time; float elapsed_time; + float seek_where; enum muteframe mute_frame; long *frame_offsets; mad_timer_t *times; @@ -998,11 +999,8 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r) data->mute_frame = MUTEFRAME_NONE; break; case MUTEFRAME_SEEK: - if (decoder_seek_where(decoder) <= data->elapsed_time) { - decoder_clear(decoder); + if (data->elapsed_time >= data->seek_where) data->mute_frame = MUTEFRAME_NONE; - decoder_command_finished(decoder); - } break; case MUTEFRAME_NONE: cmd = mp3_synth_and_send(data, @@ -1025,8 +1023,12 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r) decoder_command_finished(decoder); } else decoder_seek_error(decoder); - } else + } else { + data->seek_where = decoder_seek_where(decoder); data->mute_frame = MUTEFRAME_SEEK; + decoder_clear(decoder); + decoder_command_finished(decoder); + } } } |