From 8b0b4ff0860ea93850c2f44e72e8a8a5de05e13b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 1 Sep 2011 07:13:21 +0200 Subject: output_thread: reimplement CANCEL synchronization The output thread could hang indefinitely after finishing CANCEL, because it could have missed the signal while the output was not unlocked in ao_command_finished(). This patch removes the wait() call after CANCEL, and adds the flag "allow_play" instead. While this flag is set, playback is skipped. With this flag, there will not be any excess wait() call after the pipe has been cleared. This patch fixes a bug that causes mpd to discontinue playback after seeking, due to the race condition described above. --- src/output_internal.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/output_internal.h') diff --git a/src/output_internal.h b/src/output_internal.h index 18d43135..7102ea5c 100644 --- a/src/output_internal.h +++ b/src/output_internal.h @@ -109,6 +109,15 @@ struct audio_output { */ bool pause; + /** + * When this flag is set, the output thread will not do any + * playback. It will wait until the flag is cleared. + * + * This is used to synchronize the "clear" operation on the + * shared music pipe during the CANCEL command. + */ + bool allow_play; + /** * If not NULL, the device has failed, and this timer is used * to estimate how long it should stay disabled (unless -- cgit v1.2.3