how to close, clean, and restart the audio engine

edited December 2015

Hello

I'm having a hard time to figure out how to clean properly the audio engine : stop it, remove all channels... and later restart it.

To focus on the problem I wrote a small test app with (TAAE v1.5.4) that just add 20 block channels, start the engine, remove all the channels and stop the engine.

If I repeat that several times, the app simply crashes. I my real app, it causes warnings "Update graph: -10861" (kAUGraphErr_InvalidConnection), sometimes crashes.
On iPhone6s, the situation is the worst : no sound anymore, even when you close the app. The only way to bring back sound in iOS is to plug headphones.

Here is the code for the small test app :
start button :

- (IBAction)startButtonPushed:(id)sender
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[[appDelegate audioController] addChannels:channels]
[appDelegate.audioController start:nil]
}

stop button :

- (IBAction)stopButtonPushed:(id)sender
{
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.audioController removeChannels:appDelegate.audioController.channels];
[appDelegate.audioController stop];
}

initialisation :

for (int i = 0; i< 20 ; i++)
    {
        AEBlockChannel* newBlockChannel = [AEBlockChannel channelWithBlock:^(const AudioTimeStamp  *time, UInt32 frames, AudioBufferList *audio)
        {
        }];
       [channels addObject:newBlockChannel];
    }

Thanks for your help !

Sign In or Register to comment.