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 <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-01 22:48:25 -08:00
parent 074e4115dd
commit 002be384ff
2 changed files with 6 additions and 2 deletions

View File

@ -47,6 +47,8 @@
atomic_int refCount; atomic_int refCount;
int currentPlaybackStatus; int currentPlaybackStatus;
BOOL shouldContinue;
} }
- (id)init; - (id)init;

View File

@ -251,6 +251,8 @@
- (void)setShouldContinue:(BOOL)s - (void)setShouldContinue:(BOOL)s
{ {
shouldContinue = s;
if (bufferChain) if (bufferChain)
[bufferChain setShouldContinue:s]; [bufferChain setShouldContinue:s];
@ -344,7 +346,7 @@
} }
} }
while (duration >= 30.0) while (duration >= 30.0 && shouldContinue)
{ {
[semaphore wait]; [semaphore wait];
if (atomic_load_explicit(&resettingNow, memory_order_relaxed)) { if (atomic_load_explicit(&resettingNow, memory_order_relaxed)) {
@ -416,7 +418,7 @@
lastChain = nil; lastChain = nil;
while (![newChain open:nextStream withOutputFormat:[output format] withRGInfo:nextStreamRGInfo]) while (shouldContinue && ![newChain open:nextStream withOutputFormat:[output format] withRGInfo:nextStreamRGInfo])
{ {
if (nextStream == nil) if (nextStream == nil)
{ {