aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-11 20:50:37 +0100
committerMax Kellermann <max@duempel.org>2008-11-11 20:50:37 +0100
commit514c37b0cdf763e5bf9c487bd9d8b90930230e78 (patch)
tree15c2c6a2e24e4b1c3e960c4f4d225addd51cf6e4
parent1bfa6a94e2259201068d7a947507eb5e6e93c0c3 (diff)
downloadmpd-514c37b0cdf763e5bf9c487bd9d8b90930230e78.tar.gz
mpd-514c37b0cdf763e5bf9c487bd9d8b90930230e78.tar.xz
mpd-514c37b0cdf763e5bf9c487bd9d8b90930230e78.zip
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.
Diffstat (limited to '')
-rw-r--r--src/decoder/mp3_plugin.c38
1 files changed, 20 insertions, 18 deletions
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;
}