Inheritance: MonoBehaviour
Example #1
0
 private void OnDestroy()
 {
     if (AkTerminator.ms_Instance == this)
     {
         AkTerminator.ms_Instance = null;
     }
 }
Example #2
0
 private void OnDestroy()
 {
     if (ms_Instance == this)
     {
         ms_Instance = null;
     }
 }
	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();
		AkBankManager.Reset ();
	}
Example #4
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();
    }
Example #5
0
 private void Awake()
 {
     if (AkTerminator.ms_Instance != null)
     {
         if (AkTerminator.ms_Instance != this)
         {
             Object.DestroyImmediate(this);
         }
         return;
     }
     Object.DontDestroyOnLoad(this);
     AkTerminator.ms_Instance = this;
 }
	void Awake()
	{
		if (ms_Instance != null)
		{			
			//Check if there are 2 objects with this script.  If yes, remove this component.
			if (ms_Instance != this)
				Object.DestroyImmediate(this);
            return; 
		}

		DontDestroyOnLoad(this);
		ms_Instance = this;		
	}	
Example #7
0
 private void Awake()
 {
     if (ms_Instance != null)
     {
         if (ms_Instance != this)
         {
             UnityEngine.Object.DestroyImmediate(this);
         }
     }
     else
     {
         UnityEngine.Object.DontDestroyOnLoad(this);
         ms_Instance = this;
     }
 }
Example #8
0
    void Awake()
    {
        if (ms_Instance != null)
        {
            //Check if there are 2 objects with this script.  If yes, remove this component.
            if (ms_Instance != this)
            {
                Object.DestroyImmediate(this);
            }
            return;
        }

        DontDestroyOnLoad(this);
        ms_Instance = this;
    }
Example #9
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();
    }
Example #10
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();
     }
 }
Example #11
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();
 }
	void OnDestroy()
    {   
		if (ms_Instance == this)
			ms_Instance = null;        
    }
Example #13
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 ();
	}