From 7236f83999e345645c41f53365d0a7dc7c55016d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 15 Apr 2024 21:32:19 +0200 Subject: [PATCH] player/Thread: do not start the decoder twice Upon receiving PlayerCommand::QUEUE, call StartDecoder() only if the decoder is not already starting. Checking just DecoderControl::IsIdle() is not enough because the decoder may already have finished decoding the song before the player has started playing it and before it had a chance to call CheckDecoderStartup(). Omitting the StartDecoder() call now means it will be started later in the Run() main loop, after CheckDecoderStartup() has succeeded (which effectively switches to the song that has already been decoded by the current decoder). This fixes an assertion failure when compiled in debug mode (`-Db_ndebug=false`) and random noise playback in non-debug mode (`-Db_ndebug=true`). Closes https://github.com/MusicPlayerDaemon/MPD/issues/1900 --- src/player/Thread.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 01cca7b8f..91f2810ea 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -785,7 +785,7 @@ Player::ProcessCommand(std::unique_lock &lock) noexcept queued = true; pc.CommandFinished(); - if (dc.IsIdle()) + if (!decoder_starting && dc.IsIdle()) StartDecoder(lock, std::make_shared(), false);