diff options
author | Max Kellermann <max@duempel.org> | 2008-10-29 16:13:51 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-29 16:13:51 +0100 |
commit | a6ad0e40471f652bd58ed2ea2a0409050b66b279 (patch) | |
tree | 288324f0c1481f728b247b47aa16157d6045fc2e /src | |
parent | 0d079ee51532d076da31c19cbfb2695c7c6d3cf6 (diff) | |
download | mpd-a6ad0e40471f652bd58ed2ea2a0409050b66b279.tar.gz mpd-a6ad0e40471f652bd58ed2ea2a0409050b66b279.tar.xz mpd-a6ad0e40471f652bd58ed2ea2a0409050b66b279.zip |
mp3: moved code to mp3_update_timer_next_frame()
Break the large function mp3_read() into smaller pieces.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/mp3_plugin.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index 529e9ced6..a36f979bf 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -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: |