aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-02 19:09:25 +0100
committerMax Kellermann <max@duempel.org>2009-11-02 19:09:25 +0100
commitb9013944dc80c70533aaaa0d5a446500a49e0607 (patch)
treee30a133db1a7e718afb2c58a46de824706daa627
parente814f8d5bd0f701710fd44cf3743f00226ad67f0 (diff)
downloadmpd-b9013944dc80c70533aaaa0d5a446500a49e0607.tar.gz
mpd-b9013944dc80c70533aaaa0d5a446500a49e0607.tar.xz
mpd-b9013944dc80c70533aaaa0d5a446500a49e0607.zip
output: signal the output thread when CANCEL is finished
After CANCEL, the output thread waits for another signal before it continues playback, to synchronize with the caller. There were some situations where this signal wasn't sent properly. This patch adds an explicit g_cond_signal() at two code positions.
Diffstat (limited to '')
-rw-r--r--src/output_all.c30
-rw-r--r--src/output_control.c4
2 files changed, 34 insertions, 0 deletions
diff --git a/src/output_all.c b/src/output_all.c
index bdf0385bb..7c411f14f 100644
--- a/src/output_all.c
+++ b/src/output_all.c
@@ -202,6 +202,29 @@ static void audio_output_wait_all(void)
notify_wait(&audio_output_client_notify);
}
+/**
+ * Signals the audio output if it is open. This function locks the
+ * mutex.
+ */
+static void
+audio_output_lock_signal(struct audio_output *ao)
+{
+ g_mutex_lock(ao->mutex);
+ if (audio_output_is_open(ao))
+ g_cond_signal(ao->cond);
+ g_mutex_unlock(ao->mutex);
+}
+
+/**
+ * Signals all audio outputs which are open.
+ */
+static void
+audio_output_signal_all(void)
+{
+ for (unsigned i = 0; i < num_audio_outputs; ++i)
+ audio_output_lock_signal(&audio_outputs[i]);
+}
+
static void
audio_output_reset_reopen(struct audio_output *ao)
{
@@ -488,6 +511,13 @@ audio_output_all_cancel(void)
if (g_mp != NULL)
music_pipe_clear(g_mp, g_music_buffer);
+ /* the audio outputs are now waiting for a signal, to
+ synchronize the cleared music pipe */
+
+ audio_output_signal_all();
+
+ /* invalidate elapsed_time */
+
audio_output_all_elapsed_time = -1.0;
}
diff --git a/src/output_control.c b/src/output_control.c
index c54ce4f92..842b89030 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -128,6 +128,10 @@ audio_output_open(struct audio_output *ao,
/* we're not using audio_output_cancel() here,
because that function is asynchronous */
ao_command(ao, AO_COMMAND_CANCEL);
+
+ /* the audio output is now waiting for a
+ signal; wake it up immediately */
+ g_cond_signal(ao->cond);
}
return true;