Skip to content

Commit

Permalink
Fixed a nasty block capture within sample app's render block
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltyson committed Jun 12, 2016
1 parent 09441c4 commit be100cf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions TAAESample/Classes/AEAudioController.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ - (instancetype)init {

// Setup top-level renderer. This is all performed on the audio thread, so the usual
// rules apply: No holding locks, no memory allocation, no Objective-C/Swift code.
__unsafe_unretained AEAudioController * THIS = self;
renderer.block = ^(const AERenderContext * _Nonnull context) {

// See if we have an active recorder
Expand All @@ -166,8 +167,9 @@ - (instancetype)init {

// Sweep balance
float bal = 0.0;
if ( _balanceSweepRate > 0 ) {
bal = AEDSPGenerateOscillator((1.0/_balanceSweepRate) / (context->sampleRate/context->frames), &balanceLfo) * 2 - 1;
if ( THIS->_balanceSweepRate > 0 ) {
bal = AEDSPGenerateOscillator((1.0/THIS->_balanceSweepRate)
/ (context->sampleRate/context->frames), &balanceLfo) * 2 - 1;
} else {
balanceLfo = 0.5;
}
Expand All @@ -181,7 +183,7 @@ - (instancetype)init {
// Put on output
AERenderContextOutput(context, 1);

if ( _inputEnabled ) {
if ( THIS->_inputEnabled ) {
// Add audio input
AEModuleProcess(input, context);

Expand All @@ -191,7 +193,7 @@ - (instancetype)init {
AEDSPApplyGain(AEBufferStackGet(context->stack, 0), 2.0, context->frames);

// If it's safe to do so, put this on the output
if ( !_playingThroughSpeaker ) {
if ( !THIS->_playingThroughSpeaker ) {
if ( player ) {
// If we're playing a recording, duck first
AEDSPApplyGain(AEBufferStackGet(context->stack, 0), 0.1, context->frames);
Expand All @@ -203,7 +205,7 @@ - (instancetype)init {

// Run through recorder, if it's there
if ( recorder && !player ) {
if ( _inputEnabled ) {
if ( THIS->_inputEnabled ) {
// We have a buffer from input to mix in
AEBufferStackMix(context->stack, 2);
}
Expand Down

0 comments on commit be100cf

Please sign in to comment.