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.
This commit is contained in:
parent
de588448df
commit
d6c4441c78
@ -110,6 +110,7 @@ struct mp3_data {
|
|||||||
int32_t output_buffer[MP3_DATA_OUTPUT_BUFFER_SIZE];
|
int32_t output_buffer[MP3_DATA_OUTPUT_BUFFER_SIZE];
|
||||||
float total_time;
|
float total_time;
|
||||||
float elapsed_time;
|
float elapsed_time;
|
||||||
|
float seek_where;
|
||||||
enum muteframe mute_frame;
|
enum muteframe mute_frame;
|
||||||
long *frame_offsets;
|
long *frame_offsets;
|
||||||
mad_timer_t *times;
|
mad_timer_t *times;
|
||||||
@ -998,11 +999,8 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
|
|||||||
data->mute_frame = MUTEFRAME_NONE;
|
data->mute_frame = MUTEFRAME_NONE;
|
||||||
break;
|
break;
|
||||||
case MUTEFRAME_SEEK:
|
case MUTEFRAME_SEEK:
|
||||||
if (decoder_seek_where(decoder) <= data->elapsed_time) {
|
if (data->elapsed_time >= data->seek_where)
|
||||||
decoder_clear(decoder);
|
|
||||||
data->mute_frame = MUTEFRAME_NONE;
|
data->mute_frame = MUTEFRAME_NONE;
|
||||||
decoder_command_finished(decoder);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MUTEFRAME_NONE:
|
case MUTEFRAME_NONE:
|
||||||
cmd = mp3_synth_and_send(data,
|
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);
|
decoder_command_finished(decoder);
|
||||||
} else
|
} else
|
||||||
decoder_seek_error(decoder);
|
decoder_seek_error(decoder);
|
||||||
} else
|
} else {
|
||||||
|
data->seek_where = decoder_seek_where(decoder);
|
||||||
data->mute_frame = MUTEFRAME_SEEK;
|
data->mute_frame = MUTEFRAME_SEEK;
|
||||||
|
decoder_clear(decoder);
|
||||||
|
decoder_command_finished(decoder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user