aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/decoder/mp3_plugin.c44
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: