Пример #1
0
    void Terminate()
    {
        if (ms_Instance == null || ms_Instance != this || !AkSoundEngine.IsInitialized())
        {
            return;             //Don't term twice
        }
        // Mop up the last callbacks that will be sent from Term with blocking.
        // It may happen that the term sends so many callbacks that it will use up
        // all the callback memory buffer and lock the calling thread.

        // WG-25356 Thread is unsupported in Windows Store App API.

        AkSoundEngine.StopAll();
        AkSoundEngine.RenderAudio();
        const double IdleMs       = 1.0;
        const uint   IdleTryCount = 50;

        for (uint i = 0; i < IdleTryCount; i++)
        {
            AkCallbackManager.PostCallbacks();
            using (EventWaitHandle tmpEvent = new ManualResetEvent(false)) {
                tmpEvent.WaitOne(System.TimeSpan.FromMilliseconds(IdleMs));
            }
        }

        AkSoundEngine.Term();

        ms_Instance = null;

        AkCallbackManager.Term();
    }
Пример #2
0
 private void LateUpdate()
 {
     if (ms_Instance != null)
     {
         AkCallbackManager.PostCallbacks();
         AkSoundEngine.RenderAudio();
     }
 }
Пример #3
0
 //Use LateUpdate instead of Update() to ensure all gameobjects positions, listener positions, environements, RTPC, etc are set before finishing the audio frame.
 void LateUpdate()
 {
     //Execute callbacks that occured in last frame (not the current update)
     if (ms_Instance != null)
     {
         AkCallbackManager.PostCallbacks();
         AkSoundEngine.RenderAudio();
     }
 }
Пример #4
0
 private void LateUpdate()
 {
     if (AkInitializer.ms_Instance != null)
     {
         AkCallbackManager.PostCallbacks();
         AkBankManager.DoUnloadBanks();
         AkSoundEngine.RenderAudio();
     }
 }
Пример #5
0
 //Use LateUpdate instead of Update() to ensure all gameobjects positions, listener positions, environements, RTPC, etc are set before finishing the audio frame.
 void LateUpdate()
 {
     //Execute callbacks that occured in last frame (not the current update)
     if (ms_Instance != null)
     {
         AkCallbackManager.PostCallbacks();
         AkBankManager.DoUnloadBanks();
         AkAudioListener.DefaultListeners.Refresh();
         AkSoundEngine.RenderAudio();
     }
 }
    public void Terminate()
    {
#if UNITY_EDITOR
        ClearInitializeState();

        if (!IsSoundEngineLoaded)
        {
            return;
        }
#endif

        if (!AkSoundEngine.IsInitialized())
        {
            return;
        }

        // Stop everything, and make sure the callback buffer is empty. We try emptying as much as possible, and wait 10 ms before retrying.
        // Callbacks can take a long time to be posted after the call to RenderAudio().
        AkSoundEngine.StopAll();
        AkSoundEngine.ClearBanks();
        AkSoundEngine.RenderAudio();
        var retry = 5;
        do
        {
            var numCB = 0;
            do
            {
                numCB = AkCallbackManager.PostCallbacks();

                // This is a WSA-friendly sleep
                using (System.Threading.EventWaitHandle tmpEvent = new System.Threading.ManualResetEvent(false))
                {
                    tmpEvent.WaitOne(System.TimeSpan.FromMilliseconds(1));
                }
            }while (numCB > 0);

            // This is a WSA-friendly sleep
            using (System.Threading.EventWaitHandle tmpEvent = new System.Threading.ManualResetEvent(false))
            {
                tmpEvent.WaitOne(System.TimeSpan.FromMilliseconds(10));
            }

            retry--;
        }while (retry > 0);

        AkSoundEngine.Term();

        // Make sure we have no callbacks left after Term. Some might be posted during termination.
        AkCallbackManager.PostCallbacks();

        AkCallbackManager.Term();
        AkBankManager.Reset();
    }
    public void LateUpdate()
    {
        //Execute callbacks that occurred in last frame (not the current update)
        AkCallbackManager.PostCallbacks();
        AkBankManager.DoUnloadBanks();

        if (Application.isPlaying)
        {
            AkAudioListener.DefaultListeners.Refresh();
        }

        AkSoundEngine.RenderAudio();
    }
    public void LateUpdate()
    {
#if UNITY_EDITOR
        if (!IsSoundEngineLoaded)
        {
            return;
        }
#endif

        //Execute callbacks that occurred in last frame (not the current update)
        AkCallbackManager.PostCallbacks();
        AkSoundEngine.RenderAudio();
    }
    public void LateUpdate()
    {
#if UNITY_EDITOR
        if (!IsSoundEngineLoaded)
        {
            return;
        }
#endif

        //Execute callbacks that occurred in last frame (not the current update)
        AkCallbackManager.PostCallbacks();
        AkBankManager.DoUnloadBanks();
        AkAudioListener.DefaultListeners.Refresh();
        AkSoundEngine.RenderAudio();
    }
Пример #10
0
    void Terminate()
    {
        if (ms_Instance == null || ms_Instance != this || !AkSoundEngine.IsInitialized())
        {
            return;             //Don't term twice
        }
        // Stop everything, and make sure the callback buffer is empty. We try emptying as much as possible, and wait 10 ms before retrying.
        // Callbacks can take a long time to be posted after the call to RenderAudio().
        AkCallbackManager.SetMonitoringCallback(0, null);
        AkSoundEngine.StopAll();
        AkSoundEngine.ClearBanks();
        AkSoundEngine.RenderAudio();
        int retry = 5;

        do
        {
            int numCB = 0;
            do
            {
                numCB = AkCallbackManager.PostCallbacks();

                // This is a WSA-friendly sleep
                using (EventWaitHandle tmpEvent = new ManualResetEvent(false))
                {
                    tmpEvent.WaitOne(System.TimeSpan.FromMilliseconds(1));
                }
            }while(numCB > 0);

            // This is a WSA-friendly sleep
            using (EventWaitHandle tmpEvent = new ManualResetEvent(false))
            {
                tmpEvent.WaitOne(System.TimeSpan.FromMilliseconds(10));
            }
            retry--;
        }while (retry > 0);

        AkSoundEngine.Term();

        // Make sure we have no callbacks left after Term. Some might be posted during termination.
        AkCallbackManager.PostCallbacks();
        ms_Instance = null;

        AkCallbackManager.Term();
        AkBankManager.Reset();
    }
    public void LateUpdate()
    {
#if UNITY_EDITOR
        if (!AkSoundEngine.EditorIsSoundEngineLoaded)
        {
            return;
        }
#endif

        //Execute callbacks that occurred in last frame (not the current update)
        AkRoomManager.Update();
        AkRoomAwareManager.UpdateRoomAwareObjects();
        AkCallbackManager.PostCallbacks();
#if !(AK_WWISE_ADDRESSABLES && UNITY_ADDRESSABLES)
        AkBankManager.DoUnloadBanks();
#endif
        AkSoundEngine.RenderAudio();
    }
Пример #12
0
 private void Terminate()
 {
     if (((ms_Instance != null) && (ms_Instance == this)) && AkSoundEngine.IsInitialized())
     {
         AkSoundEngine.StopAll();
         AkSoundEngine.RenderAudio();
         for (uint i = 0; i < 50; i++)
         {
             AkCallbackManager.PostCallbacks();
             using (EventWaitHandle handle = new ManualResetEvent(false))
             {
                 handle.WaitOne(TimeSpan.FromMilliseconds(1.0));
             }
         }
         AkSoundEngine.Term();
         ms_Instance = null;
         AkCallbackManager.Term();
     }
 }
Пример #13
0
 private void Terminate()
 {
     if (AkTerminator.ms_Instance == null || AkTerminator.ms_Instance != this || !AkSoundEngine.IsInitialized())
     {
         return;
     }
     AkSoundEngine.StopAll();
     AkSoundEngine.RenderAudio();
     for (uint num = 0u; num < 50u; num += 1u)
     {
         AkCallbackManager.PostCallbacks();
         using (EventWaitHandle eventWaitHandle = new ManualResetEvent(false))
         {
             eventWaitHandle.WaitOne(TimeSpan.FromMilliseconds(1.0));
         }
     }
     AkSoundEngine.Term();
     AkTerminator.ms_Instance = null;
     AkCallbackManager.Term();
 }