Commit 3888ef2f authored by Max Kellermann's avatar Max Kellermann

decoder_control: properly cancel an existing command in dc_stop()

When the decoder thread has a pending command, send the STOP command to cancel this command. Send STOP again if the decoder thread is still running after that, just in case the decoder thread has executed the previous command (which was overwritten).
parent ceb00f78
......@@ -80,8 +80,14 @@ dc_start_async(struct song *song)
void
dc_stop(struct notify *notify)
{
if (dc.command == DECODE_COMMAND_START ||
(dc.state != DECODE_STATE_STOP && dc.state != DECODE_STATE_ERROR))
if (dc.command != DECODE_COMMAND_NONE)
/* Attempt to cancel the current command. If it's too
late and the decoder thread is already executing
the old command, we'll call STOP again in this
function (see below). */
dc_command(notify, DECODE_COMMAND_STOP);
if (dc.state != DECODE_STATE_STOP && dc.state != DECODE_STATE_ERROR)
dc_command(notify, DECODE_COMMAND_STOP);
}
......
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