Do not get the AudioListenerInterruptionEnd trigge

2019-07-13 08:46发布

问题:

I have a problem with the combination of OpenAl and the MPMoviePlayerController.

I registered the AudioInterruptionLister in my OpenAl Setup process. When I start a video the listener receives the AudioListenerInterruptionStarts, but when the movie ends I do not receive the AudioListenerInterruptionEnd trigger.

// Register callback for audio interrupts
AudioSessionInitialize(NULL, NULL, &OpenALInterruptionListener, this);

The listener

void OpenALInterruptionListener(void *inClientData, UInt32 inInterruptionState) 
{
    OpenAL *oal = (OpenAL *) inClientData;

    if (inInterruptionState == kAudioSessionBeginInterruption) 
    {
        oal->MakeContextNull();
        AudioSessionSetActive(false);
    } 
    else if (inInterruptionState == kAudioSessionEndInterruption) 
    {
        AudioSessionSetActive(true);
       oal->MakeContextCurrent();
    }
}

My solution until now was to make the context invalid before starting the movie and make it current after movie ends. That leads to the problem, that if the user skips the movie very fast by touching the screen, I make the context current and a little bit delayed I get AudioListenerInterruptionStart trigger that sets my context to null again.

On iOs greater 3.1 I can set useApplicationAudioSession = NO and the listener does never becomes a start or end trigger. But on iOS lower than 3.2 htis option does not exists.

But my main question is, why does I never get the AudioListenerInterruptionEnd trigger.

Thanks for help best regards Georg