internal static IntPtr getCPtr(AkAudioInterruptionCallbackInfo obj)
 {
     return((obj == null) ? IntPtr.Zero : obj.swigCPtr);
 }
Ejemplo n.º 2
0
    /// This function dispatches all the accumulated callbacks from the native sound engine.
    /// It must be called regularly.  By default this is called in AkInitializer.cs.
    static public int PostCallbacks()
    {
        if (m_pNotifMem == IntPtr.Zero)
        {
            return(0);
        }

        try
        {
            int numCallbacks = 0;

            for (IntPtr pNext = AkCallbackSerializer.Lock(); pNext != IntPtr.Zero; pNext = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pNext_get(pNext), ++numCallbacks)
            {
                IntPtr         pPackage = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pPackage_get(pNext);
                AkCallbackType eType    = (AkCallbackType)AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_eType_get(pNext);
                IntPtr         pData    = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_GetData(pNext);

                switch (eType)
                {
                case AkCallbackType.AK_AudioInterruption:
#if UNITY_IOS && !UNITY_EDITOR
                    if (ms_interruptCallbackPkg != null && ms_interruptCallbackPkg.m_Callback != null)
                    {
                        using (AkAudioInterruptionCallbackInfo info = new AkAudioInterruptionCallbackInfo(pData, false))
                            ms_interruptCallbackPkg.m_Callback(info.bEnterInterruption, ms_interruptCallbackPkg.m_Cookie);
                    }
#endif // #if UNITY_IOS && ! UNITY_EDITOR
                    break;

                case AkCallbackType.AK_AudioSourceChange:
                    if (ms_sourceChangeCallbackPkg != null && ms_sourceChangeCallbackPkg.m_Callback != null)
                    {
                        using (AkAudioSourceChangeCallbackInfo info = new AkAudioSourceChangeCallbackInfo(pData, false))
                            ms_sourceChangeCallbackPkg.m_Callback(info.bOtherAudioPlaying, ms_sourceChangeCallbackPkg.m_Cookie);
                    }
                    break;

                case AkCallbackType.AK_Monitoring:
                    if (m_MonitoringCB != null)
                    {
                        using (AkMonitoringCallbackInfo info = new AkMonitoringCallbackInfo(pData, false))
                            m_MonitoringCB(info.errorCode, info.errorLevel, info.playingID, info.gameObjID, info.message);
                    }
                    break;

                case AkCallbackType.AK_Bank:
                    BankCallbackPackage bankPkg = null;
                    if (!m_mapBankCallbacks.TryGetValue((int)pPackage, out bankPkg))
                    {
                        Debug.LogError("WwiseUnity: BankCallbackPackage not found for <" + pPackage + ">.");
                        return(numCallbacks);
                    }
                    else
                    {
                        m_mapBankCallbacks.Remove((int)pPackage);

                        if (bankPkg != null && bankPkg.m_Callback != null)
                        {
                            using (AkBankCallbackInfo info = new AkBankCallbackInfo(pData, false))
                                bankPkg.m_Callback(info.bankID, info.inMemoryBankPtr, info.loadResult, (uint)info.memPoolId, bankPkg.m_Cookie);
                        }
                    }
                    break;

                default:
                    EventCallbackPackage eventPkg = null;
                    if (!m_mapEventCallbacks.TryGetValue((int)pPackage, out eventPkg))
                    {
                        Debug.LogError("WwiseUnity: EventCallbackPackage not found for <" + pPackage + ">.");
                        return(numCallbacks);
                    }
                    else
                    {
                        AkCallbackInfo info = null;

                        switch (eType)
                        {
                        case AkCallbackType.AK_EndOfEvent:
                            m_mapEventCallbacks.Remove(eventPkg.GetHashCode());
                            if (eventPkg.m_bNotifyEndOfEvent)
                            {
                                info = new AkEventCallbackInfo(pData, false);
                            }
                            break;

                        case AkCallbackType.AK_MusicPlayStarted:
                            info = new AkEventCallbackInfo(pData, false);
                            break;

                        case AkCallbackType.AK_EndOfDynamicSequenceItem:
                            info = new AkDynamicSequenceItemCallbackInfo(pData, false);
                            break;

                        case AkCallbackType.AK_MIDIEvent:
                            info = new AkMIDIEventCallbackInfo(pData, false);
                            break;

                        case AkCallbackType.AK_Marker:
                            info = new AkMarkerCallbackInfo(pData, false);
                            break;

                        case AkCallbackType.AK_Duration:
                            info = new AkDurationCallbackInfo(pData, false);
                            break;

                        case AkCallbackType.AK_MusicSyncUserCue:
                        case AkCallbackType.AK_MusicSyncBar:
                        case AkCallbackType.AK_MusicSyncBeat:
                        case AkCallbackType.AK_MusicSyncEntry:
                        case AkCallbackType.AK_MusicSyncExit:
                        case AkCallbackType.AK_MusicSyncGrid:
                        case AkCallbackType.AK_MusicSyncPoint:
                            info = new AkMusicSyncCallbackInfo(pData, false);
                            break;

                        case AkCallbackType.AK_MusicPlaylistSelect:
                            info = new AkMusicPlaylistCallbackInfo(pData, false);
                            break;

                        default:
                            Debug.LogError("WwiseUnity: PostCallbacks aborted due to error: Undefined callback type <" + eType + "> found. Callback object possibly corrupted.");
                            return(numCallbacks);
                        }

                        if (info != null)
                        {
                            eventPkg.m_Callback(eventPkg.m_Cookie, eType, info);
                        }
                    }
                    break;
                }
            }

            return(numCallbacks);
        }
        finally
        {
            AkCallbackSerializer.Unlock();
        }
    }