Commit 78c55e24 authored by Max Kellermann's avatar Max Kellermann

added decoder_command_finished() to decoder_api.h

Some decoder commands are implemented in the decoder plugins, thus they need to have an API call to signal that their current command has been finished. Let them use the new decoder_command_finished() instead of the internal dc_command_finished().
parent 817a68b2
...@@ -48,14 +48,6 @@ static void dc_command(enum decoder_command cmd) ...@@ -48,14 +48,6 @@ static void dc_command(enum decoder_command cmd)
dc_command_wait(); dc_command_wait();
} }
void dc_command_finished(void)
{
assert(dc.command != DECODE_COMMAND_NONE);
dc.command = DECODE_COMMAND_NONE;
notify_signal(&pc.notify);
}
static void stopDecode(void) static void stopDecode(void)
{ {
if (dc.command == DECODE_COMMAND_START || if (dc.command == DECODE_COMMAND_START ||
......
...@@ -63,11 +63,4 @@ void decode(void); ...@@ -63,11 +63,4 @@ void decode(void);
void decoderInit(void); void decoderInit(void);
/**
* Called by the decoder thread when it has performed the requested
* command (dc->command). This function resets dc->command and wakes
* up the player thread.
*/
void dc_command_finished(void);
#endif #endif
...@@ -50,11 +50,20 @@ enum decoder_command decoder_get_command(mpd_unused struct decoder * decoder) ...@@ -50,11 +50,20 @@ enum decoder_command decoder_get_command(mpd_unused struct decoder * decoder)
return dc.command; return dc.command;
} }
void decoder_command_finished(mpd_unused struct decoder * decoder)
{
assert(dc.command != DECODE_COMMAND_NONE);
dc.command = DECODE_COMMAND_NONE;
notify_signal(&pc.notify);
}
/** /**
* All chunks are full of decoded data; wait for the player to free * All chunks are full of decoded data; wait for the player to free
* one. * one.
*/ */
static int need_chunks(InputStream * inStream, int seekable) static int need_chunks(struct decoder *decoder, InputStream * inStream,
int seekable)
{ {
if (dc.command == DECODE_COMMAND_STOP) if (dc.command == DECODE_COMMAND_STOP)
return OUTPUT_BUFFER_DC_STOP; return OUTPUT_BUFFER_DC_STOP;
...@@ -64,7 +73,7 @@ static int need_chunks(InputStream * inStream, int seekable) ...@@ -64,7 +73,7 @@ static int need_chunks(InputStream * inStream, int seekable)
return OUTPUT_BUFFER_DC_SEEK; return OUTPUT_BUFFER_DC_SEEK;
} else { } else {
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} }
} }
...@@ -119,7 +128,7 @@ int decoder_data(struct decoder *decoder, InputStream * inStream, ...@@ -119,7 +128,7 @@ int decoder_data(struct decoder *decoder, InputStream * inStream,
data += nbytes; data += nbytes;
if (datalen > 0) { if (datalen > 0) {
ret = need_chunks(inStream, seekable); ret = need_chunks(decoder, inStream, seekable);
if (ret != 0) if (ret != 0)
return ret; return ret;
} }
......
...@@ -106,6 +106,13 @@ void decoder_initialized(struct decoder * decoder, ...@@ -106,6 +106,13 @@ void decoder_initialized(struct decoder * decoder,
enum decoder_command decoder_get_command(struct decoder * decoder); enum decoder_command decoder_get_command(struct decoder * decoder);
/** /**
* Called by the decoder when it has performed the requested command
* (dc->command). This function resets dc->command and wakes up the
* player thread.
*/
void decoder_command_finished(struct decoder * decoder);
/**
* This function is called by the decoder plugin when it has * This function is called by the decoder plugin when it has
* successfully decoded block of input data. * successfully decoded block of input data.
* *
......
...@@ -391,7 +391,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path) ...@@ -391,7 +391,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
bitRate, NULL); bitRate, NULL);
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) { if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} else if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) } else if (decoder_get_command(decoder) == DECODE_COMMAND_STOP)
break; break;
} }
...@@ -407,7 +407,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path) ...@@ -407,7 +407,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) { if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} }
return 0; return 0;
......
...@@ -95,7 +95,7 @@ static int audiofile_decode(struct decoder * decoder, char *path) ...@@ -95,7 +95,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
current = dc.seekWhere * current = dc.seekWhere *
audio_format.sampleRate; audio_format.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current); afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
dc_command_finished(); decoder_command_finished(decoder);
} }
ret = afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk, ret = afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk,
......
...@@ -433,7 +433,7 @@ static int flac_decode_internal(struct decoder * decoder, ...@@ -433,7 +433,7 @@ static int flac_decode_internal(struct decoder * decoder,
data.position = 0; data.position = 0;
} else } else
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} }
} }
if (decoder_get_command(decoder) != DECODE_COMMAND_STOP) { if (decoder_get_command(decoder) != DECODE_COMMAND_STOP) {
......
...@@ -189,7 +189,7 @@ static int mod_decode(struct decoder * decoder, char *path) ...@@ -189,7 +189,7 @@ static int mod_decode(struct decoder * decoder, char *path)
while (1) { while (1) {
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) { if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} }
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) if (decoder_get_command(decoder) == DECODE_COMMAND_STOP)
......
...@@ -855,7 +855,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -855,7 +855,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
data->outputPtr = data->outputBuffer; data->outputPtr = data->outputBuffer;
decoder_clear(decoder); decoder_clear(decoder);
data->muteFrame = 0; data->muteFrame = 0;
dc_command_finished(); decoder_command_finished(decoder);
} }
break; break;
default: default:
...@@ -968,12 +968,12 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -968,12 +968,12 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
} else } else
dc.seekError = 1; dc.seekError = 1;
data->muteFrame = 0; data->muteFrame = 0;
dc_command_finished(); decoder_command_finished(decoder);
} }
} else if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK && } else if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
!data->inStream->seekable) { !data->inStream->seekable) {
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} }
} }
...@@ -1076,7 +1076,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream) ...@@ -1076,7 +1076,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK && if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
data.muteFrame == MUTEFRAME_SEEK) { data.muteFrame == MUTEFRAME_SEEK) {
decoder_clear(decoder); decoder_clear(decoder);
dc_command_finished(); decoder_command_finished(decoder);
} }
decoder_flush(decoder); decoder_flush(decoder);
......
...@@ -213,7 +213,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -213,7 +213,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
seekPositionFound = 0; seekPositionFound = 0;
decoder_clear(mpd_decoder); decoder_clear(mpd_decoder);
seeking = 0; seeking = 0;
dc_command_finished(); decoder_command_finished(mpd_decoder);
} }
if (seeking) if (seeking)
...@@ -284,7 +284,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -284,7 +284,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking) { if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking) {
decoder_clear(mpd_decoder); decoder_clear(mpd_decoder);
dc_command_finished(); decoder_command_finished(mpd_decoder);
} }
decoder_flush(mpd_decoder); decoder_flush(mpd_decoder);
......
...@@ -185,7 +185,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -185,7 +185,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
chunkpos = 0; chunkpos = 0;
} else } else
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(mpd_decoder);
} }
vbrUpdateAcc = 0; vbrUpdateAcc = 0;
......
...@@ -364,7 +364,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -364,7 +364,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
data.position = 0; data.position = 0;
} else } else
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(dc); decoder_command_finished(mpd_decoder);
} }
} }
......
...@@ -273,7 +273,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) ...@@ -273,7 +273,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
chunkpos = 0; chunkpos = 0;
} else } else
dc.seekError = 1; dc.seekError = 1;
dc_command_finished(); decoder_command_finished(decoder);
} }
ret = ov_read(&vf, chunk + chunkpos, ret = ov_read(&vf, chunk + chunkpos,
OGG_CHUNK_SIZE - chunkpos, OGG_CHUNK_SIZE - chunkpos,
......
...@@ -188,7 +188,7 @@ static void wavpack_decode(struct decoder * decoder, ...@@ -188,7 +188,7 @@ static void wavpack_decode(struct decoder * decoder,
dc.seekError = 1; dc.seekError = 1;
} }
dc_command_finished(); decoder_command_finished(decoder);
} }
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) if (decoder_get_command(decoder) == DECODE_COMMAND_STOP)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment