aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
commit9e0f7dcd1a9c000a78cf283af4fa593e808ed374 (patch)
tree44772658d158989ddf49b764e92d34e9135678b4 /src
parent726c6e86d304163f0453de611ce03d656d99d1d8 (diff)
downloadmpd-9e0f7dcd1a9c000a78cf283af4fa593e808ed374.tar.gz
mpd-9e0f7dcd1a9c000a78cf283af4fa593e808ed374.tar.xz
mpd-9e0f7dcd1a9c000a78cf283af4fa593e808ed374.zip
added dc_command_finished()
dc_command_finished() is invoked by the decoder thread when it has finished a command (sent by the player thread). It resets dc.command and wakes up the player thread. This combination was used at a lot of places, and by introducing this function, the code will be more readable.
Diffstat (limited to '')
-rw-r--r--src/decode.c11
-rw-r--r--src/decode.h7
-rw-r--r--src/inputPlugins/aac_plugin.c6
-rw-r--r--src/inputPlugins/audiofile_plugin.c3
-rw-r--r--src/inputPlugins/flac_plugin.c3
-rw-r--r--src/inputPlugins/mod_plugin.c3
-rw-r--r--src/inputPlugins/mp3_plugin.c12
-rw-r--r--src/inputPlugins/mp4_plugin.c6
-rw-r--r--src/inputPlugins/mpc_plugin.c3
-rw-r--r--src/inputPlugins/oggflac_plugin.c3
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c3
-rw-r--r--src/inputPlugins/wavpack_plugin.c3
-rw-r--r--src/outputBuffer.c3
13 files changed, 32 insertions, 34 deletions
diff --git a/src/decode.c b/src/decode.c
index 551f40caa..dff876296 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -70,6 +70,14 @@ static void dc_command(enum decoder_command cmd)
dc_command_wait();
}
+void dc_command_finished(void)
+{
+ assert(dc.command != DECODE_COMMAND_NONE);
+
+ dc.command = DECODE_COMMAND_NONE;
+ decoder_wakeup_player();
+}
+
static void stopDecode(void)
{
if (dc.command == DECODE_COMMAND_START ||
@@ -346,8 +354,7 @@ static void * decoder_task(mpd_unused void *arg)
dc.command == DECODE_COMMAND_SEEK) {
decodeStart();
} else if (dc.command == DECODE_COMMAND_STOP) {
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
} else {
decoder_sleep();
}
diff --git a/src/decode.h b/src/decode.h
index 9418c8789..2f60319a1 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -67,4 +67,11 @@ void decoder_sleep(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
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index 81e5d5656..2ca757392 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -396,8 +396,7 @@ static int aac_decode(char *path)
bitRate, NULL);
if (dc.command == DECODE_COMMAND_SEEK) {
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
} else if (dc.command == DECODE_COMMAND_STOP) {
eof = 1;
break;
@@ -415,8 +414,7 @@ static int aac_decode(char *path)
if (dc.command == DECODE_COMMAND_SEEK) {
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
return 0;
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 1d4000027..08c5e6e16 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -96,8 +96,7 @@ static int audiofile_decode(char *path)
current = dc.seekWhere *
dc.audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
ret =
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index 43242d2d6..a5b44c7f4 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -431,8 +431,7 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg)
data.position = 0;
} else
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
}
if (dc.command != DECODE_COMMAND_STOP) {
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 5f4adb338..40e2ef841 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -189,8 +189,7 @@ static int mod_decode(char *path)
while (1) {
if (dc.command == DECODE_COMMAND_SEEK) {
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
if (dc.command == DECODE_COMMAND_STOP)
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 30515f303..4288f85de 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -854,8 +854,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
data->outputPtr = data->outputBuffer;
ob_clear();
data->muteFrame = 0;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
break;
default:
@@ -968,14 +967,12 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
} else
dc.seekError = 1;
data->muteFrame = 0;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
} else if (dc.command == DECODE_COMMAND_SEEK &&
!data->inStream->seekable) {
- dc.command = DECODE_COMMAND_NONE;
dc.seekError = 1;
- decoder_wakeup_player();
+ dc_command_finished();
}
}
@@ -1084,8 +1081,7 @@ static int mp3_decode(InputStream * inStream)
if (dc.command == DECODE_COMMAND_SEEK &&
data.muteFrame == MUTEFRAME_SEEK) {
ob_clear();
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
ob_flush();
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index f70725f98..0bdd3e75b 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -213,8 +213,7 @@ static int mp4_decode(InputStream * inStream)
seekPositionFound = 0;
ob_clear();
seeking = 0;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
if (seeking)
@@ -290,8 +289,7 @@ static int mp4_decode(InputStream * inStream)
if (dc.command == DECODE_COMMAND_SEEK && seeking) {
ob_clear();
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
ob_flush();
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 3e4229289..c6b13cdff 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -184,8 +184,7 @@ static int mpc_decode(InputStream * inStream)
chunkpos = 0;
} else
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
vbrUpdateAcc = 0;
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 71c45aab8..552b550be 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -363,8 +363,7 @@ static int oggflac_decode(InputStream * inStream)
data.position = 0;
} else
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished(dc);
}
}
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index 91281b3a2..993035f37 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -273,8 +273,7 @@ static int oggvorbis_decode(InputStream * inStream)
chunkpos = 0;
} else
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
ret = ov_read(&vf, chunk + chunkpos,
OGG_CHUNK_SIZE - chunkpos,
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index 257f1de94..ae5f50826 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -187,8 +187,7 @@ static void wavpack_decode(WavpackContext *wpc, int canseek,
dc.seekError = 1;
}
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
if (dc.command == DECODE_COMMAND_STOP)
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 3b280e3a7..f4c56a36a 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -179,8 +179,7 @@ static int tailChunk(InputStream * inStream,
return OUTPUT_BUFFER_DC_SEEK;
} else {
dc.seekError = 1;
- dc.command = DECODE_COMMAND_NONE;
- decoder_wakeup_player();
+ dc_command_finished();
}
}
if (!inStream || bufferInputStream(inStream) <= 0) {