How to properly handle audio interruptions?

后端 未结 2 1974
时光取名叫无心
时光取名叫无心 2021-02-04 09:59

I\'ve created a OpenGL 3D game utilizing OpenAL for audio playback and experienceing a problem of losing audio if \"Home\" button is getting pressed before audio device is getti

相关标签:
2条回答
  • 2021-02-04 10:03

    Please note that there are currently issues with Audio Interruptions and IOS. Interruption notifications are fine, but end Audio Interruptions Notifications do not always work. There is a bug into Apple on this and they have not responded.

    0 讨论(0)
  • 2021-02-04 10:26

    Try using NULL in alcMakeContextCurrent()

    void OpenALInterriptionListener(void *inClientData, UInt32 inInterruptionState)
    {
        OpenALDevice * device = (OpenALDevice *) inClientData;
        OSStatus nResult;
    
        if( inInterruptionState == kAudioSessionBeginInterruption )
        {
            alcMakeContextCurrent(NULL);    
        }
        else if( inInterruptionState == kAudioSessionEndInterruption )
        {
            nResult = AudioSessionSetActive(true);
    
            if( nResult )
            {
                //  "Error setting audio session active"
            }
    
            alcMakeContextCurrent( device->GetContext() );
        }
    }
    
    0 讨论(0)
提交回复
热议问题