aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-30 06:09:28 +0100
committerMax Kellermann <max@duempel.org>2008-10-30 06:09:28 +0100
commitd29bad441066919f808c4ad1657bc5600fd9bd45 (patch)
treefbf3ea6109b72099a8567c919e94789130b540a1 /src
parentf8722913cf2f9d88cdc20a022c81d131c1728b17 (diff)
downloadmpd-d29bad441066919f808c4ad1657bc5600fd9bd45.tar.gz
mpd-d29bad441066919f808c4ad1657bc5600fd9bd45.tar.xz
mpd-d29bad441066919f808c4ad1657bc5600fd9bd45.zip
mp3: make mp3_read() return bool
Its only caller in mp3_decode() just compared its value with DECODE_BREAK. Convert that to bool, and return false if the loop should be ended. Also eliminate some superfluous command checking code, which was already done in the preceding while loop.
Diffstat (limited to 'src')
-rw-r--r--src/decoder/mp3_plugin.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c
index 452c2441c..ef5b518f8 100644
--- a/src/decoder/mp3_plugin.c
+++ b/src/decoder/mp3_plugin.c
@@ -984,7 +984,7 @@ mp3_synth_and_send(struct mp3_data *data, ReplayGainInfo *replay_gain_info)
return DECODE_COMMAND_NONE;
}
-static enum mp3_action
+static bool
mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
{
struct decoder *decoder = data->decoder;
@@ -1006,8 +1006,8 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
cmd = mp3_synth_and_send(data,
replay_gain_info_r != NULL
? *replay_gain_info_r : NULL);
- if (cmd == DECODE_COMMAND_STOP)
- return DECODE_BREAK;
+ if (cmd != DECODE_COMMAND_NONE)
+ return false;
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
unsigned long j;
@@ -1037,7 +1037,7 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
replay_gain_info_r)) == DECODE_CONT
&& decoder_get_command(decoder) == DECODE_COMMAND_NONE) ;
if (ret == DECODE_BREAK || decoder_get_command(decoder) != DECODE_COMMAND_NONE)
- break;
+ return false;
else if (ret == DECODE_SKIP)
skip = 1;
if (data->mute_frame == MUTEFRAME_NONE) {
@@ -1045,25 +1045,13 @@ mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
decoder_get_command(decoder) == DECODE_COMMAND_NONE) ;
if (ret == DECODE_BREAK ||
decoder_get_command(decoder) != DECODE_COMMAND_NONE)
- break;
+ return false;
}
if (!skip && ret == DECODE_OK)
break;
}
- switch (decoder_get_command(decoder)) {
- case DECODE_COMMAND_NONE:
- case DECODE_COMMAND_START:
- break;
-
- case DECODE_COMMAND_STOP:
- return DECODE_BREAK;
-
- case DECODE_COMMAND_SEEK:
- return DECODE_CONT;
- }
-
- return ret;
+ return ret != DECODE_BREAK;
}
static void mp3_audio_format(struct mp3_data *data, struct audio_format *af)
@@ -1122,7 +1110,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
decoder_initialized(decoder, &audio_format, data.total_time);
- while (mp3_read(&data, &replay_gain_info) != DECODE_BREAK) ;
+ while (mp3_read(&data, &replay_gain_info)) ;
if (replay_gain_info)
freeReplayGainInfo(replay_gain_info);