From 002be384ff6c0ec58ae4108c3946ff6e7755d9f8 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 1 Feb 2022 22:48:25 -0800 Subject: [PATCH] Cog Audio: Terminate queueing when stopping The end of input queueing, which can go nuts when there are a lot of short files, should be terminated when the user asks the player to stop. Signed-off-by: Christopher Snowhill --- Audio/AudioPlayer.h | 2 ++ Audio/AudioPlayer.m | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Audio/AudioPlayer.h b/Audio/AudioPlayer.h index 0b00aaeab..a85251823 100644 --- a/Audio/AudioPlayer.h +++ b/Audio/AudioPlayer.h @@ -47,6 +47,8 @@ atomic_int refCount; int currentPlaybackStatus; + + BOOL shouldContinue; } - (id)init; diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index b493b8220..3c6497867 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -251,6 +251,8 @@ - (void)setShouldContinue:(BOOL)s { + shouldContinue = s; + if (bufferChain) [bufferChain setShouldContinue:s]; @@ -344,7 +346,7 @@ } } - while (duration >= 30.0) + while (duration >= 30.0 && shouldContinue) { [semaphore wait]; if (atomic_load_explicit(&resettingNow, memory_order_relaxed)) { @@ -416,7 +418,7 @@ lastChain = nil; - while (![newChain open:nextStream withOutputFormat:[output format] withRGInfo:nextStreamRGInfo]) + while (shouldContinue && ![newChain open:nextStream withOutputFormat:[output format] withRGInfo:nextStreamRGInfo]) { if (nextStream == nil) {