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(); }
bool RegisterSettings() { #if UNITY_EDITOR AkSoundEngine.SetGameName(UnityEngine.Application.productName + " (Editor)"); #else AkSoundEngine.SetGameName(UnityEngine.Application.productName); #endif AKRESULT result = AkSoundEngine.Init(memSetting, streamingSetting, deviceSetting, initSettings, platformSetting, musicSetting, spatialSetting, instance.SettingData.preparePoolSizeKB * 1024); if (result != AKRESULT.AK_Success) { UnityEngine.Debug.LogError("WwiseUnity: Failed to initialize the sound engine. Abort."); AkSoundEngine.Term(); return(false); //AkSoundEngine.Init should have logged more details. } var basePathToSet = AkBasePathGetter.GetSoundbankBasePath(); if (string.IsNullOrEmpty(basePathToSet)) { UnityEngine.Debug.LogError("WwiseUnity: Couldn't find soundbanks base path. Terminate sound engine."); AkSoundEngine.Term(); return(false); } result = AkSoundEngine.SetBasePath(basePathToSet); if (result != AKRESULT.AK_Success) { UnityEngine.Debug.LogError("WwiseUnity: Failed to set soundbanks base path. Terminate sound engine."); AkSoundEngine.Term(); return(false); } LateInitSetting(); return(true); }