diff options
author | Max Kellermann <max@duempel.org> | 2013-11-06 23:47:30 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-06 23:51:17 +0100 |
commit | f8f95e2dbd73d0d43211136e50a8d640f145872c (patch) | |
tree | 9d4ea69a9c668f6286e0dc6de38ec5dfb650a55e /src/OutputThread.cxx | |
parent | 77c63511d8809f7785328138e7e3a50303302730 (diff) | |
download | mpd-f8f95e2dbd73d0d43211136e50a8d640f145872c.tar.gz mpd-f8f95e2dbd73d0d43211136e50a8d640f145872c.tar.xz mpd-f8f95e2dbd73d0d43211136e50a8d640f145872c.zip |
OutputControl: reduce the number of OutputThread wakeups
Wake up the OutputThread only if it hasn't already been woken up and
if it isn't already in the playback loop.
Diffstat (limited to 'src/OutputThread.cxx')
-rw-r--r-- | src/OutputThread.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/OutputThread.cxx b/src/OutputThread.cxx index c6f2e4d30..30d3ba30f 100644 --- a/src/OutputThread.cxx +++ b/src/OutputThread.cxx @@ -510,6 +510,9 @@ ao_play(struct audio_output *ao) ao->chunk_finished = false; + assert(!ao->in_playback_loop); + ao->in_playback_loop = true; + while (chunk != nullptr && ao->command == AO_COMMAND_NONE) { assert(!ao->chunk_finished); @@ -525,6 +528,9 @@ ao_play(struct audio_output *ao) chunk = chunk->next; } + assert(ao->in_playback_loop); + ao->in_playback_loop = false; + ao->chunk_finished = true; ao->mutex.unlock(); @@ -656,8 +662,10 @@ audio_output_task(void *arg) chunks in the pipe */ continue; - if (ao->command == AO_COMMAND_NONE) + if (ao->command == AO_COMMAND_NONE) { + ao->woken_for_play = false; ao->cond.wait(ao->mutex); + } } } |