Skip to content

Instantly share code, notes, and snippets.

@standinga
Created May 4, 2019 13:34
Show Gist options
  • Save standinga/d8aecfe3ccd02685cf88a31c25f4d1c8 to your computer and use it in GitHub Desktop.
Save standinga/d8aecfe3ccd02685cf88a31c25f4d1c8 to your computer and use it in GitHub Desktop.
update allocateRenderResourcesAndReturnError
- (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