AVAudioPlayerNode crashes on play

I have a very simple setup involving AVAudioEngine, and a player node, AVAudioPlayerNode.

The player node is attached to the audio engine, then connected to the engine's main mixer node.


Then, to start outputing some sound, I start the engine, and finally play the node :


NSError* err = nil;
BOOL started = [_audioEngine startAndReturnError:&err];
if(started) {
    [_playerNode play];
} else {
    // handle error
}


It happens sometimes, the app crashes (on the call to the play function) because, as the system says : "player started when engine not running".


I can't understand how this can happen, at least in the code above.

No error is returned in `err`.


Does somebody knows what happen or faced such a situation ?

Post not yet marked as solved Up vote post of vincedev Down vote post of vincedev
3.0k views

Replies

I`m facing the same problem, even I check the engine is playing before play the playerNode

Me too. Have posted a question on Stack Overflow https://stackoverflow.com/questions/57092434/avaudioplayer-play-works-avaudioplayernode-play-throws-exception

I have the same problem. I wish the play function could throw an exception rather than just make the app crash.