TAAE2: AURemoteIO::IOThread (14): EXC_BAD ACCESS when recording with AEFileRecorderModule

edited May 2016

My app crash when I try to record some audio to a file. Xcode crash on this method: ExtAudioFileWriteAsync with this error message: AURemoteIO::IOThread (14): EXC_BAD ACCESS.

Here is the code of my audioManager init:

- (id)init {
    if ( !(self = [super init]) ) return nil;
    self.renderer = [AERenderer new];
    self.track = NULL;
    self.output = [[AEAudioUnitOutput alloc] initWithRenderer:self.renderer];
    self.players = [AEArray new];
    self.input = self.output.inputModule;
    self.recorderValue = [AEManagedValue new];


    AEManagedValue *recorderValue = self.recorderValue;
    AEArray * players = self.players;
    AEAudioUnitInputModule *input = self.input;

    __weak typeof(self) weakSelf = self;

    self.renderer.block = ^(const AERenderContext * _Nonnull context) {

        AEManagedValueCommitPendingAtomicUpdates();

        __unsafe_unretained AEFileRecorderModule * recorder
            = (__bridge AEFileRecorderModule *)AEManagedValueGetValue(recorderValue);

        typeof(self) strongSelf = weakSelf;

        AEArrayEnumerateObjects(players, AEAudioFilePlayerModule *, player, {
            if ( AEAudioFilePlayerModuleGetPlaying(player) ) {
                AEModuleProcess(player, context);
                AERenderContextOutput(context, 1);
                AEBufferStackPop(context->stack, 1);
            }
        });
        if ( strongSelf->_inputEnabled ) {
            AEModuleProcess(input, context);
            AEDSPApplyGain(AEBufferStackGet(context->stack, 0), 2.0, context->frames);
            if (!strongSelf.playingThroughSpeaker) {
                AERenderContextOutput(context, 1);
            }
        }
        if (recorder) {
            AEModuleProcess(recorder, context);
        }
    };
    [self start:nil];
    return self;
}

The crash start from the line AEModuleProcess(recorder, context); in my code, if I comment it, I have no error anymore.

I have really no idea from where it can come from... Have you any idea of what am I doing wrong ?

Comments

  • Hey @YoanGJ - Hmm, no, no idea off the top of my head! Could you put this into a minimal sample app that reproduces the issue?

  • edited May 2016

    Hi @Michael ! Yes of course, here is an imitation of the sample project of your Youtube video where I've commented 4 lines in the renderer block to record the input only.
    The crash appears randomly when I press the record button.

  • Ah! Found it, and fixed in SHA b3dabe407 - try now =)

  • edited May 2016

    PER-FECT ! Thank you ! =)

Sign In or Register to comment.