aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/output_control.c11
-rw-r--r--src/output_internal.h6
-rw-r--r--src/output_thread.c3
3 files changed, 20 insertions, 0 deletions
diff --git a/src/output_control.c b/src/output_control.c
index eac9bdfcb..16c0dbb75 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -76,6 +76,17 @@ audio_output_open(struct audio_output *ao,
audio_format_equals(audio_format, &ao->in_audio_format)) {
assert(ao->pipe == mp);
+ if (ao->pause) {
+ /* unpause with the CANCEL command; this is a
+ hack, but suits well for forcing the thread
+ to leave the ao_pause() thread, and we need
+ to flush the device buffer anyway */
+
+ /* we're not using audio_output_cancel() here,
+ because that function is asynchronous */
+ ao_command(ao, AO_COMMAND_CANCEL);
+ }
+
return true;
}
diff --git a/src/output_internal.h b/src/output_internal.h
index 362d24947..72596c1c3 100644
--- a/src/output_internal.h
+++ b/src/output_internal.h
@@ -81,6 +81,12 @@ struct audio_output {
bool open;
/**
+ * Is the device paused? i.e. the output thread is in the
+ * ao_pause() loop.
+ */
+ bool pause;
+
+ /**
* If not NULL, the device has failed, and this timer is used
* to estimate how long it should stay disabled (unless
* explicitly reopened with "play").
diff --git a/src/output_thread.c b/src/output_thread.c
index d414ba8d5..785ac808f 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -165,6 +165,7 @@ static void ao_pause(struct audio_output *ao)
bool ret;
ao_plugin_cancel(ao->plugin, ao->data);
+ ao->pause = true;
ao_command_finished(ao);
do {
@@ -174,6 +175,8 @@ static void ao_pause(struct audio_output *ao)
break;
}
} while (ao->command == AO_COMMAND_NONE);
+
+ ao->pause = false;
}
static gpointer audio_output_task(gpointer arg)