Created
April 27, 2010 05:15
-
-
Save ddribin/380346 to your computer and use it in GitHub Desktop.
goto, no macro
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
- (BOOL)play:(NSError **)error; | |
{ | |
NSAssert(_graph == NULL, @"Graph is already started"); | |
OSStatus status; | |
status = NewAUGraph(&_graph); | |
if (status != noErr) | |
goto failed; | |
status = [self addOutputNode]; | |
if (status != noErr) | |
goto failed; | |
status = [self addConverterNode]; | |
if (status != noErr) | |
goto failed; | |
status = AUGraphConnectNodeInput(_graph, _converterNode, 0, _outputNode, 0); | |
if (status != noErr) | |
goto failed; | |
status = AUGraphOpen(_graph); | |
if (status != noErr) | |
goto failed; | |
[self setupDataFormat]; | |
status = [self setDataFormatOfConverterAudioUnit]; | |
if (status != noErr) | |
goto failed; | |
status = [self setMaximumFramesPerSlice]; | |
if (status != noErr) | |
goto failed; | |
status = [self setRenderCallbackOfConverterNode]; | |
if (status != noErr) | |
goto failed; | |
status = AUGraphInitialize(_graph); | |
if (status != noErr) | |
goto failed; | |
A440SineWaveGeneratorInitWithFrequency(&_sineWaveGenerator, 440.0); | |
status = AUGraphStart(_graph); | |
if (status != noErr) | |
goto failed; | |
return YES; | |
failed: | |
if (_graph != NULL) { | |
DisposeAUGraph(_graph); | |
} | |
if (error != NULL) { | |
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil]; | |
} | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment