aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decode.c54
-rw-r--r--src/decode.h11
-rw-r--r--src/inputPlugins/_flac_common.c2
-rw-r--r--src/inputPlugins/aac_plugin.c14
-rw-r--r--src/inputPlugins/audiofile_plugin.c19
-rw-r--r--src/inputPlugins/flac_plugin.c15
-rw-r--r--src/inputPlugins/mod_plugin.c6
-rw-r--r--src/inputPlugins/mp3_plugin.c51
-rw-r--r--src/inputPlugins/mp4_plugin.c14
-rw-r--r--src/inputPlugins/mpc_plugin.c17
-rw-r--r--src/inputPlugins/oggflac_plugin.c15
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c14
-rw-r--r--src/inputPlugins/wavpack_plugin.c8
-rw-r--r--src/outputBuffer.c6
-rw-r--r--src/playerData.c1
15 files changed, 139 insertions, 108 deletions
diff --git a/src/decode.c b/src/decode.c
index 467dc68cb..02f806488 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -56,19 +56,30 @@ static void player_wakeup_decoder(void)
player_sleep();
}
+static void dc_command_wait(void)
+{
+ while (dc.command != DECODE_COMMAND_NONE)
+ player_wakeup_decoder_nb();
+}
+
+static void dc_command(enum decoder_command cmd)
+{
+ dc.command = cmd;
+ dc_command_wait();
+}
+
static void stopDecode(void)
{
- if (dc.start || dc.state != DECODE_STATE_STOP) {
- dc.stop = 1;
- do { player_wakeup_decoder_nb(); } while (dc.stop);
- }
+ if (dc.command == DECODE_COMMAND_START ||
+ dc.state != DECODE_STATE_STOP)
+ dc_command(DECODE_COMMAND_STOP);
}
static void quitDecode(void)
{
stopDecode();
pc.state = PLAYER_STATE_STOP;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
pc.play = 0;
pc.stop = 0;
pc.pause = 0;
@@ -101,7 +112,7 @@ static unsigned calculateCrossFadeChunks(AudioFormat * af, float totalTime)
static int waitOnDecode(int *decodeWaitedOn)
{
- while (dc.start)
+ while (dc.command == DECODE_COMMAND_START)
player_wakeup_decoder();
if (dc.error != DECODE_ERROR_NOERROR) {
@@ -133,7 +144,7 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
ob_clear();
dc.next_song = pc.next_song;
dc.error = DECODE_ERROR_NOERROR;
- dc.start = 1;
+ dc.command = DECODE_COMMAND_START;
waitOnDecode(decodeWaitedOn);
}
if (dc.state != DECODE_STATE_STOP && dc.seekable) {
@@ -142,8 +153,7 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
pc.totalTime - 0.1 : pc.seekWhere;
dc.seekWhere = 0 > dc.seekWhere ? 0 : dc.seekWhere;
dc.seekError = 0;
- dc.seek = 1;
- do { player_wakeup_decoder(); } while (dc.seek);
+ dc_command(DECODE_COMMAND_SEEK);
if (!dc.seekError) {
pc.elapsedTime = dc.seekWhere;
ret = 0;
@@ -231,12 +241,12 @@ static void decodeStart(void)
}
dc.state = DECODE_STATE_START;
- dc.start = 0;
+ dc.command = DECODE_COMMAND_NONE;
/* for http streams, seekable is determined in bufferInputStream */
dc.seekable = inStream.seekable;
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
goto stop;
ret = DECODE_ERROR_UNKTYPE;
@@ -318,7 +328,7 @@ stop:
closeInputStream(&inStream);
stop_no_close:
dc.state = DECODE_STATE_STOP;
- dc.stop = 0;
+ dc.command = DECODE_COMMAND_NONE;
}
static void * decoder_task(mpd_unused void *arg)
@@ -328,10 +338,11 @@ static void * decoder_task(mpd_unused void *arg)
while (1) {
assert(dc.state == DECODE_STATE_STOP);
- if (dc.start || dc.seek) {
+ if (dc.command == DECODE_COMMAND_START ||
+ dc.command == DECODE_COMMAND_SEEK) {
decodeStart();
- } else if (dc.stop) {
- dc.stop = 0;
+ } else if (dc.command == DECODE_COMMAND_STOP) {
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
} else {
decoder_sleep();
@@ -480,12 +491,13 @@ static void decodeParent(void)
next = ob.end;
dc.next_song = pc.next_song;
dc.error = DECODE_ERROR_NOERROR;
- dc.start = 1;
+ dc.command = DECODE_COMMAND_START;
pc.queueState = PLAYER_QUEUE_DECODE;
wakeup_main_task();
player_wakeup_decoder_nb();
}
- if (next >= 0 && do_xfade == XFADE_UNKNOWN && !dc.start &&
+ if (next >= 0 && do_xfade == XFADE_UNKNOWN &&
+ dc.command != DECODE_COMMAND_START &&
dc.state != DECODE_STATE_START) {
/* enable cross fading in this song? if yes,
calculate how many chunks will be required
@@ -578,7 +590,8 @@ static void decodeParent(void)
pc.queueState = PLAYER_QUEUE_EMPTY;
wakeup_main_task();
- } else if (dc.state == DECODE_STATE_STOP && !dc.start) {
+ } else if (dc.state == DECODE_STATE_STOP &&
+ dc.command != DECODE_COMMAND_START) {
break;
} else {
/*DEBUG("waiting for decoded audio, play silence\n");*/
@@ -600,10 +613,7 @@ void decode(void)
ob_clear();
dc.next_song = pc.next_song;
dc.error = DECODE_ERROR_NOERROR;
- dc.seek = 0;
- dc.stop = 0;
- dc.start = 1;
- do { player_wakeup_decoder(); } while (dc.start);
+ dc_command(DECODE_COMMAND_START);
decodeParent();
}
diff --git a/src/decode.h b/src/decode.h
index 990f5e57a..9418c8789 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -33,6 +33,13 @@ enum decoder_state {
DECODE_STATE_DECODE
};
+enum decoder_command {
+ DECODE_COMMAND_NONE = 0,
+ DECODE_COMMAND_START,
+ DECODE_COMMAND_STOP,
+ DECODE_COMMAND_SEEK
+};
+
#define DECODE_ERROR_NOERROR 0
#define DECODE_ERROR_UNKTYPE 10
#define DECODE_ERROR_FILE 20
@@ -41,10 +48,8 @@ typedef struct _DecoderControl {
Notify notify;
volatile enum decoder_state state;
- volatile mpd_sint8 stop;
- volatile mpd_sint8 start;
+ volatile enum decoder_command command;
volatile mpd_uint16 error;
- volatile mpd_sint8 seek;
volatile mpd_sint8 seekError;
volatile mpd_sint8 seekable;
volatile double seekWhere;
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index a1c68b8ea..9e70662be 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -177,7 +177,7 @@ void flac_error_common_cb(const char *plugin,
const FLAC__StreamDecoderErrorStatus status,
mpd_unused FlacData * data)
{
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
return;
switch (status) {
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index f1c1d9303..81e5d5656 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -392,13 +392,13 @@ static int aac_decode(char *path)
sampleBufferLen = sampleCount * 2;
ob_send(NULL, 0, sampleBuffer,
- sampleBufferLen, file_time,
- bitRate, NULL);
- if (dc.seek) {
+ sampleBufferLen, file_time,
+ bitRate, NULL);
+ if (dc.command == DECODE_COMMAND_SEEK) {
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
- } else if (dc.stop) {
+ } else if (dc.command == DECODE_COMMAND_STOP) {
eof = 1;
break;
}
@@ -413,9 +413,9 @@ static int aac_decode(char *path)
if (dc.state != DECODE_STATE_DECODE)
return -1;
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index edc2d4b90..1d4000027 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -91,12 +91,12 @@ static int audiofile_decode(char *path)
char chunk[CHUNK_SIZE];
while (!eof) {
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
ob_clear();
current = dc.seekWhere *
dc.audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
@@ -108,14 +108,13 @@ static int audiofile_decode(char *path)
else {
current += ret;
ob_send(NULL,
- 1,
- chunk,
- ret * fs,
- (float)current /
- (float)dc.audioFormat.
- sampleRate, bitRate,
- NULL);
- if (dc.stop)
+ 1,
+ chunk, ret * fs,
+ (float)current /
+ (float)dc.audioFormat.
+ sampleRate, bitRate,
+ NULL);
+ if (dc.command == DECODE_COMMAND_STOP)
break;
}
}
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index 37adae810..43242d2d6 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -35,14 +35,15 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec,
while (1) {
r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes);
- if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop)
+ if (r == 0 && !inputStreamAtEOF(data->inStream) &&
+ dc.command != DECODE_COMMAND_STOP)
my_usleep(10000);
else
break;
}
*bytes = r;
- if (r == 0 && !dc.stop) {
+ if (r == 0 && dc.command != DECODE_COMMAND_STOP) {
if (inputStreamAtEOF(data->inStream))
return flac_read_status_eof;
else
@@ -285,7 +286,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
data->chunk_length = 0;
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
@@ -420,7 +421,7 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg)
break;
if (flac_get_state(flacDec) == flac_decoder_eof)
break;
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
FLAC__uint64 sampleToSeek = dc.seekWhere *
dc.audioFormat.sampleRate + 0.5;
if (flac_seek_absolute(flacDec, sampleToSeek)) {
@@ -430,16 +431,16 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg)
data.position = 0;
} else
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
}
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
flacPrintErroredState(flac_get_state(flacDec));
flac_finish(flacDec);
}
/* send last little bit */
- if (data.chunk_length > 0 && !dc.stop) {
+ if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
flacSendChunk(&data);
ob_flush();
}
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 21da58328..5f4adb338 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -187,13 +187,13 @@ static int mod_decode(char *path)
dc.state = DECODE_STATE_DECODE;
while (1) {
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
break;
if (!Player_Active())
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 982496acb..30515f303 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -684,13 +684,17 @@ static int decodeFirstFrame(mp3DecodeData * data,
while (1) {
while ((ret = decodeNextFrameHeader(data, tag, replayGainInfo)) == DECODE_CONT &&
- !dc.stop);
- if (ret == DECODE_BREAK || dc.stop) return -1;
+ dc.command != DECODE_COMMAND_STOP);
+ if (ret == DECODE_BREAK ||
+ (dc.command == DECODE_COMMAND_STOP))
+ return -1;
if (ret == DECODE_SKIP) continue;
while ((ret = decodeNextFrame(data)) == DECODE_CONT &&
- !dc.stop);
- if (ret == DECODE_BREAK || dc.stop) return -1;
+ dc.command != DECODE_COMMAND_STOP);
+ if (ret == DECODE_BREAK ||
+ (dc.command == DECODE_COMMAND_STOP))
+ return -1;
if (ret == DECODE_OK) break;
}
@@ -850,7 +854,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
data->outputPtr = data->outputBuffer;
ob_clear();
data->muteFrame = 0;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
break;
@@ -944,7 +948,8 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
data->decodedFirstFrame = 1;
- if (dc.seek && data->inStream->seekable) {
+ if (dc.command == DECODE_COMMAND_SEEK &&
+ data->inStream->seekable) {
long j = 0;
data->muteFrame = MUTEFRAME_SEEK;
while (j < data->highestFrame && dc.seekWhere >
@@ -963,11 +968,12 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
} else
dc.seekError = 1;
data->muteFrame = 0;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
- } else if (dc.seek && !data->inStream->seekable) {
- dc.seek = 0;
+ } else if (dc.command == DECODE_COMMAND_SEEK &&
+ !data->inStream->seekable) {
+ dc.command = DECODE_COMMAND_NONE;
dc.seekError = 1;
decoder_wakeup_player();
}
@@ -978,22 +984,27 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
while ((ret =
decodeNextFrameHeader(data, NULL,
replayGainInfo)) == DECODE_CONT
- && !dc.stop) ;
- if (ret == DECODE_BREAK || dc.stop || dc.seek)
+ && dc.command != DECODE_COMMAND_STOP) ;
+ if (ret == DECODE_BREAK ||
+ dc.command == DECODE_COMMAND_STOP ||
+ dc.command == DECODE_COMMAND_SEEK)
break;
else if (ret == DECODE_SKIP)
skip = 1;
if (!data->muteFrame) {
while ((ret = decodeNextFrame(data)) == DECODE_CONT &&
- !dc.stop && !dc.seek) ;
- if (ret == DECODE_BREAK || dc.stop || dc.seek)
+ dc.command != DECODE_COMMAND_STOP &&
+ dc.command != DECODE_COMMAND_SEEK) ;
+ if (ret == DECODE_BREAK ||
+ dc.command == DECODE_COMMAND_STOP ||
+ dc.command == DECODE_COMMAND_SEEK)
break;
}
if (!skip && ret == DECODE_OK)
break;
}
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
return DECODE_BREAK;
return ret;
@@ -1015,7 +1026,7 @@ static int mp3_decode(InputStream * inStream)
if (openMp3FromInputStream(inStream, &data, &tag, &replayGainInfo) <
0) {
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
ERROR
("Input does not appear to be a mp3 bit stream.\n");
return -1;
@@ -1056,8 +1067,9 @@ static int mp3_decode(InputStream * inStream)
dc.state = DECODE_STATE_DECODE;
while (mp3Read(&data, &replayGainInfo) != DECODE_BREAK) ;
- /* send last little bit if not dc.stop */
- if (!dc.stop && data.outputPtr != data.outputBuffer && data.flush) {
+ /* send last little bit if not DECODE_COMMAND_STOP */
+ if (dc.command != DECODE_COMMAND_STOP &&
+ data.outputPtr != data.outputBuffer && data.flush) {
ob_send(NULL,
data.inStream->seekable,
data.outputBuffer,
@@ -1069,9 +1081,10 @@ static int mp3_decode(InputStream * inStream)
if (replayGainInfo)
freeReplayGainInfo(replayGainInfo);
- if (dc.seek && data.muteFrame == MUTEFRAME_SEEK) {
+ if (dc.command == DECODE_COMMAND_SEEK &&
+ data.muteFrame == MUTEFRAME_SEEK) {
ob_clear();
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index 2731e5fbe..f70725f98 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -178,7 +178,7 @@ static int mp4_decode(InputStream * inStream)
seekTable = xmalloc(sizeof(float) * numSamples);
for (sampleId = 0; sampleId < numSamples && !eof; sampleId++) {
- if (dc.seek)
+ if (dc.command == DECODE_COMMAND_SEEK)
seeking = 1;
if (seeking && seekTableEnd > 1 &&
@@ -213,7 +213,7 @@ static int mp4_decode(InputStream * inStream)
seekPositionFound = 0;
ob_clear();
seeking = 0;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
@@ -272,9 +272,9 @@ static int mp4_decode(InputStream * inStream)
sampleBuffer += offset * channels * 2;
ob_send(inStream, 1, sampleBuffer,
- sampleBufferLen, file_time,
- bitRate, NULL);
- if (dc.stop) {
+ sampleBufferLen, file_time,
+ bitRate, NULL);
+ if (dc.command == DECODE_COMMAND_STOP) {
eof = 1;
break;
}
@@ -288,9 +288,9 @@ static int mp4_decode(InputStream * inStream)
if (dc.state != DECODE_STATE_DECODE)
return -1;
- if (dc.seek && seeking) {
+ if (dc.command == DECODE_COMMAND_SEEK && seeking) {
ob_clear();
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
ob_flush();
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 =
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 7fce1551b..71c45aab8 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -50,14 +50,15 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const
while (1) {
r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes);
if (r == 0 && !inputStreamAtEOF(data->inStream) &&
- !dc.stop)
+ dc.command != DECODE_COMMAND_STOP)
my_usleep(10000);
else
break;
}
*bytes = r;
- if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop)
+ if (r == 0 && !inputStreamAtEOF(data->inStream) &&
+ dc.command != DECODE_COMMAND_STOP)
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
@@ -194,7 +195,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
data->chunk_length = 0;
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
@@ -351,7 +352,7 @@ static int oggflac_decode(InputStream * inStream)
OggFLAC__SEEKABLE_STREAM_DECODER_OK) {
break;
}
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
FLAC__uint64 sampleToSeek = dc.seekWhere *
dc.audioFormat.sampleRate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
@@ -362,18 +363,18 @@ static int oggflac_decode(InputStream * inStream)
data.position = 0;
} else
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
}
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
oggflacPrintErroredState
(OggFLAC__seekable_stream_decoder_get_state(decoder));
OggFLAC__seekable_stream_decoder_finish(decoder);
}
/* send last little bit */
- if (data.chunk_length > 0 && !dc.stop) {
+ if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
flacSendChunk(&data);
ob_flush();
}
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index 1722a7ed0..91281b3a2 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -60,7 +60,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
while (1) {
ret = readFromInputStream(data->inStream, ptr, size, nmemb);
if (ret == 0 && !inputStreamAtEOF(data->inStream) &&
- !dc.stop) {
+ dc.command != DECODE_COMMAND_STOP) {
my_usleep(10000);
} else
break;
@@ -74,7 +74,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
{
const OggCallbackData *data = (const OggCallbackData *) vdata;
- if (dc.stop)
+ if(dc.command == DECODE_COMMAND_STOP)
return -1;
return seekInputStream(data->inStream, offset, whence);
}
@@ -234,7 +234,7 @@ static int oggvorbis_decode(InputStream * inStream)
callbacks.close_func = ogg_close_cb;
callbacks.tell_func = ogg_tell_cb;
if ((ret = ov_open_callbacks(&data, &vf, NULL, 0, callbacks)) < 0) {
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
switch (ret) {
case OV_EREAD:
errorStr = "read error";
@@ -267,13 +267,13 @@ static int oggvorbis_decode(InputStream * inStream)
dc.audioFormat.bits = 16;
while (1) {
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
if (0 == ov_time_seek_page(&vf, dc.seekWhere)) {
ob_clear();
chunkpos = 0;
} else
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
ret = ov_read(&vf, chunk + chunkpos,
@@ -317,12 +317,12 @@ static int oggvorbis_decode(InputStream * inStream)
dc.audioFormat.sampleRate,
bitRate, replayGainInfo);
chunkpos = 0;
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
break;
}
}
- if (!dc.stop && chunkpos > 0) {
+ if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
ob_send(NULL, inStream->seekable,
chunk, chunkpos,
ov_time_tell(&vf), bitRate,
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index 1e1b97593..257f1de94 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -171,7 +171,7 @@ static void wavpack_decode(WavpackContext *wpc, int canseek,
position = 0;
do {
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
if (canseek) {
int where;
@@ -187,11 +187,11 @@ static void wavpack_decode(WavpackContext *wpc, int canseek,
dc.seekError = 1;
}
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
break;
samplesgot = WavpackUnpackSamples(wpc,
@@ -501,7 +501,7 @@ static int wavpack_streamdecode(InputStream *is)
break;
}
- if (dc.stop) {
+ if (dc.command == DECODE_COMMAND_STOP) {
break;
}
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index b0cfc00df..3b280e3a7 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -171,15 +171,15 @@ static int tailChunk(InputStream * inStream,
/* all chunks are full of decoded data; wait
for the player to free one */
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
return OUTPUT_BUFFER_DC_STOP;
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
if (seekable) {
return OUTPUT_BUFFER_DC_SEEK;
} else {
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
}
diff --git a/src/playerData.c b/src/playerData.c
index 3934d0c6f..f268c85c6 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -84,6 +84,7 @@ void initPlayerData(void)
notify_init(&dc.notify);
dc.state = DECODE_STATE_STOP;
+ dc.command = DECODE_COMMAND_NONE;
dc.error = DECODE_ERROR_NOERROR;
}