diff options
Diffstat (limited to '')
-rw-r--r-- | src/output/shout_plugin.c | 7 | ||||
-rw-r--r-- | src/output_control.c | 11 | ||||
-rw-r--r-- | src/output_internal.h | 6 | ||||
-rw-r--r-- | src/output_thread.c | 3 |
4 files changed, 27 insertions, 0 deletions
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c index 8e091679e..4412d26ff 100644 --- a/src/output/shout_plugin.c +++ b/src/output/shout_plugin.c @@ -448,8 +448,15 @@ my_shout_play(void *data, const void *chunk, size_t size, GError **error) static bool my_shout_pause(void *data) { + struct shout_data *sd = (struct shout_data *)data; static const char silence[1020]; + if (shout_delay(sd->shout_conn) > 500) { + /* cap the latency for unpause */ + g_usleep(500000); + return true; + } + return my_shout_play(data, silence, sizeof(silence), NULL); } diff --git a/src/output_control.c b/src/output_control.c index 70c6d2b1a..ef77bf4fa 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -77,6 +77,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 6ca179287..4eb77cc49 100644 --- a/src/output_internal.h +++ b/src/output_internal.h @@ -87,6 +87,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 c7bd069b1..e1f20e580 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -295,6 +295,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 { @@ -304,6 +305,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) |