diff options
author | Max Kellermann <max@duempel.org> | 2012-08-14 22:30:46 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-08-14 22:30:46 +0200 |
commit | 335d5d5d72acb310e7853c64c1d2ca1404f9f62f (patch) | |
tree | b4890247811a6fa7f2a8c9814282fd7c87f8f4a4 /src/output | |
parent | 51d793bec1f61e7048188ac4f86964486ab79142 (diff) | |
download | mpd-335d5d5d72acb310e7853c64c1d2ca1404f9f62f.tar.gz mpd-335d5d5d72acb310e7853c64c1d2ca1404f9f62f.tar.xz mpd-335d5d5d72acb310e7853c64c1d2ca1404f9f62f.zip |
output/pulse: implement method delay()
Reduce command latency while paused.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/pulse_output_plugin.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/output/pulse_output_plugin.c b/src/output/pulse_output_plugin.c index 42908fbcf..e267427df 100644 --- a/src/output/pulse_output_plugin.c +++ b/src/output/pulse_output_plugin.c @@ -762,6 +762,24 @@ pulse_output_stream_pause(struct pulse_output *po, bool pause, return true; } +static unsigned +pulse_output_delay(struct audio_output *ao) +{ + struct pulse_output *po = (struct pulse_output *)ao; + unsigned result = 0; + + pa_threaded_mainloop_lock(po->mainloop); + + if (po->base.pause && pulse_output_stream_is_paused(po) && + pa_stream_get_state(po->stream) == PA_STREAM_READY) + /* idle while paused */ + result = 1000; + + pa_threaded_mainloop_unlock(po->mainloop); + + return result; +} + static size_t pulse_output_play(struct audio_output *ao, const void *chunk, size_t size, GError **error_r) @@ -889,13 +907,8 @@ pulse_output_pause(struct audio_output *ao) /* cork the stream */ - if (pulse_output_stream_is_paused(po)) { - /* already paused; due to a MPD API limitation, we - have to sleep a little bit here, to avoid hogging - the CPU */ - - g_usleep(50000); - } else if (!pulse_output_stream_pause(po, true, &error)) { + if (!pulse_output_stream_is_paused(po) && + !pulse_output_stream_pause(po, true, &error)) { pa_threaded_mainloop_unlock(po->mainloop); g_warning("%s", error->message); g_error_free(error); @@ -932,6 +945,7 @@ const struct audio_output_plugin pulse_output_plugin = { .enable = pulse_output_enable, .disable = pulse_output_disable, .open = pulse_output_open, + .delay = pulse_output_delay, .play = pulse_output_play, .cancel = pulse_output_cancel, .pause = pulse_output_pause, |