Change suggestions to interruptionListener to make it possible to correctly handle temporary interruptions


#1

To correctly handle temporary interruptions like a phone call I need to differentiate between the begin and the end of an interruption. I therefore suggest the following small change:

    void interruptionListener (const UInt32 interruptionType)

    {

        if (interruptionType == kAudioSessionBeginInterruption)

        {

            isRunning = false;

            AudioOutputUnitStop (audioUnit);

            AudioSessionSetActive (false);


            const ScopedLock sl (callbackLock);


            if (callback != nullptr)

                callback->audioDeviceError ("iOS audio session begin interruption");

        }


        if (interruptionType == kAudioSessionEndInterruption)

        {

            isRunning = true;

            AudioSessionSetActive (true);

            AudioOutputUnitStart (audioUnit);

            

            const ScopedLock sl (callbackLock);

            

            if (callback != nullptr)

                callback->audioDeviceError ("iOS audio session end interruption");

        }

    }

Its not a perfect solution but works great for me.


#2

Hmm. Not a bad idea, actually, I might add that. Would need to keep the original error string the same though, in case people are checking for it.