From 755147b48a52f01b550dcaa9ac536d5586bf43f0 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sun, 20 Oct 2013 22:04:09 -0700 Subject: [PATCH] Through a bit of ugliness and interface exposure, the InputNode will now pause the OutputNode while it is making the decoder seek, which prevents cases of the output continuing to run for seconds at a time during a slow seek operation by decoders such as HighlyComplete --- Audio/Chain/BufferChain.h | 2 ++ Audio/Chain/BufferChain.m | 5 +++++ Audio/Chain/InputNode.m | 6 ++++++ Audio/Chain/OutputNode.h | 4 ++++ Audio/Chain/OutputNode.m | 10 ++++++++++ 5 files changed, 27 insertions(+) diff --git a/Audio/Chain/BufferChain.h b/Audio/Chain/BufferChain.h index f24b6f513..17cab6918 100644 --- a/Audio/Chain/BufferChain.h +++ b/Audio/Chain/BufferChain.h @@ -61,4 +61,6 @@ - (BOOL)isRunning; +- (id)controller; + @end diff --git a/Audio/Chain/BufferChain.m b/Audio/Chain/BufferChain.m index 1ce5a17d4..461d2ada7 100644 --- a/Audio/Chain/BufferChain.m +++ b/Audio/Chain/BufferChain.m @@ -207,4 +207,9 @@ return NO; } +- (id)controller +{ + return controller; +} + @end diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index 19c7dbd7a..a36b532b9 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -10,6 +10,8 @@ #import "BufferChain.h" #import "Plugin.h" #import "CoreAudioUtils.h" +#import "AudioPlayer.h" +#import "OutputNode.h" #import "Logging.h" @@ -120,8 +122,12 @@ { if (shouldSeek == YES) { + OutputNode *output = [[controller controller] output]; + BOOL isPaused = [output isPaused]; + if ( !isPaused ) [output pause]; DLog(@"SEEKING!"); [decoder seek:seekFrame]; + if ( !isPaused ) [output resume]; shouldSeek = NO; DLog(@"Seeked! Resetting Buffer"); diff --git a/Audio/Chain/OutputNode.h b/Audio/Chain/OutputNode.h index 81f7b0b71..e325dd352 100644 --- a/Audio/Chain/OutputNode.h +++ b/Audio/Chain/OutputNode.h @@ -20,6 +20,8 @@ unsigned long long amountPlayed; OutputCoreAudio *output; + + BOOL paused; } - (double)amountPlayed; @@ -41,4 +43,6 @@ - (void)pause; - (void)resume; +- (BOOL)isPaused; + @end diff --git a/Audio/Chain/OutputNode.m b/Audio/Chain/OutputNode.m index b9f5fd11f..c7972c3d8 100644 --- a/Audio/Chain/OutputNode.m +++ b/Audio/Chain/OutputNode.m @@ -18,6 +18,8 @@ - (void)setup { amountPlayed = 0; + + paused = YES; output = [[OutputCoreAudio alloc] initWithController:self]; @@ -33,16 +35,19 @@ - (void)process { + paused = NO; [output start]; } - (void)pause { + paused = YES; [output pause]; } - (void)resume { + paused = NO; [output resume]; } @@ -111,4 +116,9 @@ // if (s == NO) // [output stop]; } + +- (BOOL)isPaused +{ + return paused; +} @end