aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/mpc_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:07 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:07 +0200
commit817a68b2b27dc65fb5fc550c83117832e8048c6f (patch)
tree324fed7254ab6d8c64bf5736049ab50ce558af5f /src/inputPlugins/mpc_plugin.c
parent2e9169de9d859fd5d5629a4d1b3789155a5dac62 (diff)
downloadmpd-817a68b2b27dc65fb5fc550c83117832e8048c6f.tar.gz
mpd-817a68b2b27dc65fb5fc550c83117832e8048c6f.tar.xz
mpd-817a68b2b27dc65fb5fc550c83117832e8048c6f.zip
added decoder_get_command()
Another big patch which hides internal mpd APIs from decoder plugins: decoder plugins regularly poll dc->command; expose it with a decoder_api.h function.
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/mpc_plugin.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 399adf972..ff378fe7b 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -27,6 +27,7 @@
typedef struct _MpcCallbackData {
InputStream *inStream;
+ struct decoder *decoder;
} MpcCallbackData;
static mpc_int32_t mpc_read_cb(void *vdata, void *ptr, mpc_int32_t size)
@@ -37,7 +38,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.command != DECODE_COMMAND_STOP))
+ (data->decoder &&
+ decoder_get_command(data->decoder) != DECODE_COMMAND_STOP))
my_usleep(10000);
else
break;
@@ -132,6 +134,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
ReplayGainInfo *replayGainInfo = NULL;
data.inStream = inStream;
+ data.decoder = mpd_decoder;
reader.read = mpc_read_cb;
reader.seek = mpc_seek_cb;
@@ -143,7 +146,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_streaminfo_init(&info);
if ((ret = mpc_streaminfo_read(&info, &reader)) != ERROR_CODE_OK) {
- if (dc.command != DECODE_COMMAND_STOP) {
+ if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) {
ERROR("Not a valid musepack stream\n");
return -1;
}
@@ -153,7 +156,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_decoder_setup(&decoder, &reader);
if (!mpc_decoder_initialize(&decoder, &info)) {
- if (dc.command != DECODE_COMMAND_STOP) {
+ if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) {
ERROR("Not a valid musepack stream\n");
return -1;
}
@@ -174,7 +177,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_streaminfo_get_length(&info));
while (!eof) {
- if (dc.command == DECODE_COMMAND_SEEK) {
+ if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
samplePos = dc.seekWhere * audio_format.sampleRate;
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
decoder_clear(mpd_decoder);
@@ -190,7 +193,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
ret = mpc_decoder_decode(&decoder, sample_buffer,
&vbrUpdateAcc, &vbrUpdateBits);
- if (ret <= 0 || dc.command == DECODE_COMMAND_STOP) {
+ if (ret <= 0 || decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) {
eof = 1;
break;
}
@@ -221,7 +224,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
chunkpos = 0;
s16 = (mpd_sint16 *) chunk;
- if (dc.command == DECODE_COMMAND_STOP) {
+ if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) {
eof = 1;
break;
}
@@ -229,7 +232,8 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
}
}
- if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
+ if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP &&
+ chunkpos > 0) {
total_time = ((float)samplePos) / audio_format.sampleRate;
bitRate =
@@ -257,6 +261,7 @@ static float mpcGetTime(char *file)
MpcCallbackData data;
data.inStream = &inStream;
+ data.decoder = NULL;
reader.read = mpc_read_cb;
reader.seek = mpc_seek_cb;