Fixed ConverterNode listener

CQTexperiment
Chris Moeller 2013-10-10 20:02:02 -07:00
parent 442501c43f
commit c29583ec42
2 changed files with 17 additions and 11 deletions

View File

@ -31,7 +31,7 @@
AudioStreamBasicDescription outputFormat; AudioStreamBasicDescription outputFormat;
} }
- (void)registerObservers; - (id)initWithController:(id)c previous:(id)p;
- (BOOL)setupWithInputFormat:(AudioStreamBasicDescription)inputFormat outputFormat:(AudioStreamBasicDescription)outputFormat; - (BOOL)setupWithInputFormat:(AudioStreamBasicDescription)inputFormat outputFormat:(AudioStreamBasicDescription)outputFormat;
- (void)cleanUp; - (void)cleanUp;

View File

@ -28,6 +28,19 @@ void PrintStreamDesc (AudioStreamBasicDescription *inDesc)
@implementation ConverterNode @implementation ConverterNode
- (id)initWithController:(id)c previous:(id)p
{
self = [super initWithController:c previous:p];
if (self)
{
rgInfo = nil;
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.volumeScaling" options:0 context:nil];
}
return self;
}
static const float STEREO_DOWNMIX[8-2][8][2]={ static const float STEREO_DOWNMIX[8-2][8][2]={
/*3.0*/ /*3.0*/
{ {
@ -230,12 +243,6 @@ tryagain2:
return amountRead; return amountRead;
} }
- (void)registerObservers
{
NSLog(@"REGISTERING OBSERVERS");
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.volumeScaling" options:0 context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath - (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object ofObject:(id)object
change:(NSDictionary *)change change:(NSDictionary *)change
@ -305,8 +312,6 @@ static float db_to_scale(float db)
inputFormat = inf; inputFormat = inf;
outputFormat = outf; outputFormat = outf;
[self registerObservers];
floatFormat = inputFormat; floatFormat = inputFormat;
floatFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked; floatFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
floatFormat.mBitsPerChannel = 32; floatFormat.mBitsPerChannel = 32;
@ -361,6 +366,9 @@ static float db_to_scale(float db)
- (void)dealloc - (void)dealloc
{ {
NSLog(@"Decoder dealloc"); NSLog(@"Decoder dealloc");
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.volumeScaling"];
[self cleanUp]; [self cleanUp];
[super dealloc]; [super dealloc];
} }
@ -390,8 +398,6 @@ static float db_to_scale(float db)
- (void)cleanUp - (void)cleanUp
{ {
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.volumeScaling"];
[rgInfo release]; [rgInfo release];
rgInfo = nil; rgInfo = nil;
if (converterFloat) if (converterFloat)