Created
May 4, 2019 13:34
-
-
Save standinga/d8aecfe3ccd02685cf88a31c25f4d1c8 to your computer and use it in GitHub Desktop.
update allocateRenderResourcesAndReturnError
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)allocateRenderResourcesAndReturnError:(NSError **)outError { | |
if (![super allocateRenderResourcesAndReturnError:outError]) { | |
return NO; | |
} | |
// Validate that the bus formats are compatible. | |
if (self.outputBus.format.channelCount != _inputBus.format.channelCount) { | |
if (outError) { | |
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:kAudioUnitErr_FailedInitialization userInfo:nil]; | |
NSLog(@"kAudioUnitErr_FailedInitialization at %d", __LINE__); | |
} | |
self.renderResourcesAllocated = NO; | |
return NO; | |
} | |
// Allocate your resources. | |
_buffer.maxFrames = self.maximumFramesToRender; | |
_buffer.pcmBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:_inputBus.format frameCapacity: self.maximumFramesToRender]; | |
_buffer.originalAudioBufferList = _buffer.pcmBuffer.audioBufferList; | |
_buffer.mutableAudioBufferList = _buffer.pcmBuffer.mutableAudioBufferList; | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment