From 514c37b0cdf763e5bf9c487bd9d8b90930230e78 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 11 Nov 2008 20:50:37 +0100 Subject: mp3: eliminated duplicate command check When a command is received, decode_next_frame_header() and decodeNextFrame() return DECODE_BREAK. This is already checked by both callers, which means that we can eliminate lots of decoder_get_command() checks. --- src/decoder/mp3_plugin.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index 8b63eec9d..4729a267d 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -702,7 +702,6 @@ static bool mp3_decode_first_frame(struct mp3_data *data, struct tag **tag, struct replay_gain_info **replay_gain_info_r) { - struct decoder *decoder = data->decoder; struct xing xing; struct lame lame; struct mad_bitptr ptr; @@ -714,17 +713,18 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag, xing.flags = 0; while (true) { - while ((ret = decode_next_frame_header(data, tag, replay_gain_info_r)) == DECODE_CONT && - (!decoder || decoder_get_command(decoder) == DECODE_COMMAND_NONE)); - if (ret == DECODE_BREAK || - (decoder && decoder_get_command(decoder) != DECODE_COMMAND_NONE)) + do { + ret = decode_next_frame_header(data, tag, + replay_gain_info_r); + } while (ret == DECODE_CONT); + if (ret == DECODE_BREAK) return false; if (ret == DECODE_SKIP) continue; - while ((ret = decodeNextFrame(data)) == DECODE_CONT && - (!decoder || decoder_get_command(decoder) == DECODE_COMMAND_NONE)); - if (ret == DECODE_BREAK || - (decoder && decoder_get_command(decoder) != DECODE_COMMAND_NONE)) + do { + ret = decodeNextFrame(data); + } while (ret == DECODE_CONT); + if (ret == DECODE_BREAK) return false; if (ret == DECODE_OK) break; } @@ -1021,21 +1021,23 @@ mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r) while (true) { bool skip = false; - while ((ret = - decode_next_frame_header(data, NULL, - replay_gain_info_r)) == DECODE_CONT - && decoder_get_command(decoder) == DECODE_COMMAND_NONE) ; - if (ret == DECODE_BREAK || decoder_get_command(decoder) != DECODE_COMMAND_NONE) + do { + ret = decode_next_frame_header(data, NULL, + replay_gain_info_r); + } while (ret == DECODE_CONT); + if (ret == DECODE_BREAK) return false; else if (ret == DECODE_SKIP) skip = true; + if (data->mute_frame == MUTEFRAME_NONE) { - while ((ret = decodeNextFrame(data)) == DECODE_CONT && - decoder_get_command(decoder) == DECODE_COMMAND_NONE) ; - if (ret == DECODE_BREAK || - decoder_get_command(decoder) != DECODE_COMMAND_NONE) + do { + ret = decodeNextFrame(data); + } while (ret == DECODE_CONT); + if (ret == DECODE_BREAK) return false; } + if (!skip && ret == DECODE_OK) break; } -- cgit v1.2.3