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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user