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

CQTexperiment
Chris Moeller 2013-10-20 22:04:09 -07:00
parent 761ea97e0e
commit 755147b48a
5 changed files with 27 additions and 0 deletions

View File

@ -61,4 +61,6 @@
- (BOOL)isRunning; - (BOOL)isRunning;
- (id)controller;
@end @end

View File

@ -207,4 +207,9 @@
return NO; return NO;
} }
- (id)controller
{
return controller;
}
@end @end

View File

@ -10,6 +10,8 @@
#import "BufferChain.h" #import "BufferChain.h"
#import "Plugin.h" #import "Plugin.h"
#import "CoreAudioUtils.h" #import "CoreAudioUtils.h"
#import "AudioPlayer.h"
#import "OutputNode.h"
#import "Logging.h" #import "Logging.h"
@ -120,8 +122,12 @@
{ {
if (shouldSeek == YES) if (shouldSeek == YES)
{ {
OutputNode *output = [[controller controller] output];
BOOL isPaused = [output isPaused];
if ( !isPaused ) [output pause];
DLog(@"SEEKING!"); DLog(@"SEEKING!");
[decoder seek:seekFrame]; [decoder seek:seekFrame];
if ( !isPaused ) [output resume];
shouldSeek = NO; shouldSeek = NO;
DLog(@"Seeked! Resetting Buffer"); DLog(@"Seeked! Resetting Buffer");

View File

@ -20,6 +20,8 @@
unsigned long long amountPlayed; unsigned long long amountPlayed;
OutputCoreAudio *output; OutputCoreAudio *output;
BOOL paused;
} }
- (double)amountPlayed; - (double)amountPlayed;
@ -41,4 +43,6 @@
- (void)pause; - (void)pause;
- (void)resume; - (void)resume;
- (BOOL)isPaused;
@end @end

View File

@ -19,6 +19,8 @@
{ {
amountPlayed = 0; amountPlayed = 0;
paused = YES;
output = [[OutputCoreAudio alloc] initWithController:self]; output = [[OutputCoreAudio alloc] initWithController:self];
[output setup]; [output setup];
@ -33,16 +35,19 @@
- (void)process - (void)process
{ {
paused = NO;
[output start]; [output start];
} }
- (void)pause - (void)pause
{ {
paused = YES;
[output pause]; [output pause];
} }
- (void)resume - (void)resume
{ {
paused = NO;
[output resume]; [output resume];
} }
@ -111,4 +116,9 @@
// if (s == NO) // if (s == NO)
// [output stop]; // [output stop];
} }
- (BOOL)isPaused
{
return paused;
}
@end @end