Commit a6ad0e40 authored by Max Kellermann's avatar Max Kellermann

mp3: moved code to mp3_update_timer_next_frame()

Break the large function mp3_read() into smaller pieces.
parent 0d079ee5
......@@ -842,33 +842,45 @@ mp3_time_to_frame(const struct mp3_data *data, double t)
return i;
}
static enum mp3_action
mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
static void
mp3_update_timer_next_frame(struct mp3_data *data)
{
struct decoder *decoder = data->decoder;
unsigned int pcm_length, max_samples;
unsigned int i;
int ret;
int skip;
if (data->current_frame >= data->highest_frame) {
mad_timer_add(&data->timer, (data->frame).header.duration);
/* record this frame's properties in
data->frame_offsets (for seeking) and
data->times */
data->bit_rate = (data->frame).header.bitrate;
if (data->current_frame >= data->max_frames) {
if (data->current_frame >= data->max_frames)
/* cap data->current_frame */
data->current_frame = data->max_frames - 1;
} else {
else
data->highest_frame++;
}
data->frame_offsets[data->current_frame] =
mp3_this_frame_offset(data);
mad_timer_add(&data->timer, (data->frame).header.duration);
data->times[data->current_frame] = data->timer;
} else {
} else
/* get the new timer value from data->times */
data->timer = data->times[data->current_frame];
}
data->current_frame++;
data->elapsed_time =
((float)mad_timer_count(data->timer, MAD_UNITS_MILLISECONDS)) /
1000;
mad_timer_count(data->timer, MAD_UNITS_MILLISECONDS) / 1000.0;
}
static enum mp3_action
mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
{
struct decoder *decoder = data->decoder;
unsigned int pcm_length, max_samples;
unsigned int i;
int ret;
int skip;
mp3_update_timer_next_frame(data);
switch (data->mute_frame) {
case MUTEFRAME_SKIP:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment