Created
April 27, 2010 05:28
-
-
Save ddribin/380357 to your computer and use it in GitHub Desktop.
single return + helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)setError:(NSError **)error withOSStatus:(OSStatus)status | |
{ | |
if (error != NULL) { | |
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil]; | |
} | |
} | |
- (BOOL)play:(NSError **)error; | |
{ | |
NSAssert(_graph == NULL, @"Graph is already started"); | |
OSStatus status; | |
BOOL result = YES; | |
status = NewAUGraph(&_graph); | |
if (status == noErr) { | |
status = [self addOutputNode]; | |
if (status == noErr) { | |
status = [self addConverterNode]; | |
if (status == noErr) { | |
status = AUGraphConnectNodeInput(_graph, _converterNode, 0, _outputNode, 0); | |
if (status == noErr) { | |
status = AUGraphConnectNodeInput(_graph, _converterNode, 0, _outputNode, 0); | |
if (status == noErr) { | |
status = AUGraphOpen(_graph); | |
if (status == noErr) { | |
[self setupDataFormat]; | |
status = [self setDataFormatOfConverterAudioUnit]; | |
if (status == noErr) { | |
status = [self setMaximumFramesPerSlice]; | |
if (status == noErr) { | |
status = [self setRenderCallbackOfConverterNode]; | |
if (status == noErr) { | |
status = AUGraphInitialize(_graph); | |
if (status == noErr) { | |
A440SineWaveGeneratorInitWithFrequency(&_sineWaveGenerator, 440.0); | |
status = AUGraphStart(_graph); | |
if (status != noErr) { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
DisposeAUGraph(_graph); | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
} else { | |
[self setError:error withOSStatus:status]; | |
result = NO; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment