aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/mpc_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:04 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:04 +0200
commit8d3942e0c3b4108e8968e914da75bf7c6c43f408 (patch)
tree69d7eba9eb5f0273a61698169088e0ee70cdb297 /src/inputPlugins/mpc_plugin.c
parent180d78a8e631cb4d48ef468709099a8c43d7ef51 (diff)
downloadmpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.tar.gz
mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.tar.xz
mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.zip
merged start, stop, seek into DecoderControl.command
Much of the existing code queries all three variables sequentially. Since only one of them can be set at a time, this can be optimized and unified by merging all of them into one enum variable. Later, the "command" checks can be expressed in a "switch" statement.
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/mpc_plugin.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 440f41373..3e4229289 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -36,7 +36,8 @@ static mpc_int32_t mpc_read_cb(void *vdata, void *ptr, mpc_int32_t size)
while (1) {
ret = readFromInputStream(data->inStream, ptr, 1, size);
- if (ret == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop)
+ if (ret == 0 && !inputStreamAtEOF(data->inStream) &&
+ (dc.command != DECODE_COMMAND_STOP))
my_usleep(10000);
else
break;
@@ -141,7 +142,7 @@ static int mpc_decode(InputStream * inStream)
mpc_streaminfo_init(&info);
if ((ret = mpc_streaminfo_read(&info, &reader)) != ERROR_CODE_OK) {
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
ERROR("Not a valid musepack stream\n");
return -1;
}
@@ -151,7 +152,7 @@ static int mpc_decode(InputStream * inStream)
mpc_decoder_setup(&decoder, &reader);
if (!mpc_decoder_initialize(&decoder, &info)) {
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
ERROR("Not a valid musepack stream\n");
return -1;
}
@@ -175,7 +176,7 @@ static int mpc_decode(InputStream * inStream)
dc.state = DECODE_STATE_DECODE;
while (!eof) {
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
samplePos = dc.seekWhere * dc.audioFormat.sampleRate;
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
ob_clear();
@@ -183,7 +184,7 @@ static int mpc_decode(InputStream * inStream)
chunkpos = 0;
} else
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
@@ -192,7 +193,7 @@ static int mpc_decode(InputStream * inStream)
ret = mpc_decoder_decode(&decoder, sample_buffer,
&vbrUpdateAcc, &vbrUpdateBits);
- if (ret <= 0 || dc.stop) {
+ if (ret <= 0 || dc.command == DECODE_COMMAND_STOP) {
eof = 1;
break;
}
@@ -223,7 +224,7 @@ static int mpc_decode(InputStream * inStream)
chunkpos = 0;
s16 = (mpd_sint16 *) chunk;
- if (dc.stop) {
+ if (dc.command == DECODE_COMMAND_STOP) {
eof = 1;
break;
}
@@ -231,7 +232,7 @@ static int mpc_decode(InputStream * inStream)
}
}
- if (!dc.stop && chunkpos > 0) {
+ if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
total_time = ((float)samplePos) / dc.audioFormat.sampleRate;
bitRate =