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.
This commit is contained in:
Max Kellermann 2008-11-11 20:50:37 +01:00
parent 1bfa6a94e2
commit 514c37b0cd

View File

@ -702,7 +702,6 @@ static bool
mp3_decode_first_frame(struct mp3_data *data, struct tag **tag, mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
struct replay_gain_info **replay_gain_info_r) struct replay_gain_info **replay_gain_info_r)
{ {
struct decoder *decoder = data->decoder;
struct xing xing; struct xing xing;
struct lame lame; struct lame lame;
struct mad_bitptr ptr; struct mad_bitptr ptr;
@ -714,17 +713,18 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
xing.flags = 0; xing.flags = 0;
while (true) { while (true) {
while ((ret = decode_next_frame_header(data, tag, replay_gain_info_r)) == DECODE_CONT && do {
(!decoder || decoder_get_command(decoder) == DECODE_COMMAND_NONE)); ret = decode_next_frame_header(data, tag,
if (ret == DECODE_BREAK || replay_gain_info_r);
(decoder && decoder_get_command(decoder) != DECODE_COMMAND_NONE)) } while (ret == DECODE_CONT);
if (ret == DECODE_BREAK)
return false; return false;
if (ret == DECODE_SKIP) continue; if (ret == DECODE_SKIP) continue;
while ((ret = decodeNextFrame(data)) == DECODE_CONT && do {
(!decoder || decoder_get_command(decoder) == DECODE_COMMAND_NONE)); ret = decodeNextFrame(data);
if (ret == DECODE_BREAK || } while (ret == DECODE_CONT);
(decoder && decoder_get_command(decoder) != DECODE_COMMAND_NONE)) if (ret == DECODE_BREAK)
return false; return false;
if (ret == DECODE_OK) break; 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) { while (true) {
bool skip = false; bool skip = false;
while ((ret = do {
decode_next_frame_header(data, NULL, ret = decode_next_frame_header(data, NULL,
replay_gain_info_r)) == DECODE_CONT replay_gain_info_r);
&& decoder_get_command(decoder) == DECODE_COMMAND_NONE) ; } while (ret == DECODE_CONT);
if (ret == DECODE_BREAK || decoder_get_command(decoder) != DECODE_COMMAND_NONE) if (ret == DECODE_BREAK)
return false; return false;
else if (ret == DECODE_SKIP) else if (ret == DECODE_SKIP)
skip = true; skip = true;
if (data->mute_frame == MUTEFRAME_NONE) { if (data->mute_frame == MUTEFRAME_NONE) {
while ((ret = decodeNextFrame(data)) == DECODE_CONT && do {
decoder_get_command(decoder) == DECODE_COMMAND_NONE) ; ret = decodeNextFrame(data);
if (ret == DECODE_BREAK || } while (ret == DECODE_CONT);
decoder_get_command(decoder) != DECODE_COMMAND_NONE) if (ret == DECODE_BREAK)
return false; return false;
} }
if (!skip && ret == DECODE_OK) if (!skip && ret == DECODE_OK)
break; break;
} }