Commit b0596291 authored by Max Kellermann's avatar Max Kellermann

output/Thread: simplify the main loop switch

Move the InternalPlay() call and the wake_cond.wait() call into the `case Command::NONE` and revert all `continue` statements to a simple `break`.
parent 8f0a1a5d
......@@ -422,6 +422,16 @@ AudioOutputControl::Task() noexcept
while (true) {
switch (command) {
case Command::NONE:
/* no pending command: play (or wait for a
command) */
if (open && allow_play && InternalPlay(lock))
/* don't wait for an event if there
are more chunks in the pipe */
continue;
woken_for_play = false;
wake_cond.wait(lock);
break;
case Command::ENABLE:
......@@ -454,11 +464,7 @@ AudioOutputControl::Task() noexcept
}
InternalPause(lock);
/* don't "break" here: this might cause
Play() to be called when command==CLOSE
ends the paused state - "continue" checks
the new command first */
continue;
break;
case Command::RELEASE:
if (!open) {
......@@ -483,18 +489,14 @@ AudioOutputControl::Task() noexcept
CommandFinished();
}
/* don't "break" here: this might cause
Play() to be called when command==CLOSE
ends the paused state - "continue" checks
the new command first */
continue;
break;
case Command::DRAIN:
if (open)
InternalDrain();
CommandFinished();
continue;
break;
case Command::CANCEL:
source.Cancel();
......@@ -505,7 +507,7 @@ AudioOutputControl::Task() noexcept
}
CommandFinished();
continue;
break;
case Command::KILL:
InternalDisable();
......@@ -513,16 +515,6 @@ AudioOutputControl::Task() noexcept
CommandFinished();
return;
}
if (open && allow_play && InternalPlay(lock))
/* don't wait for an event if there are more
chunks in the pipe */
continue;
if (command == Command::NONE) {
woken_for_play = false;
wake_cond.wait(lock);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment