Esempio n. 1
0
        private static void OnAudioEvent(IntPtr requestInfo)
        {
            _info = null;
            _info = new AudioRequestInfo(requestInfo, true);             // requestInfo created natively , C++ will handle destruction so only a copy is needed
            uint ctrlId        = _info.ControlId;
            var  requestResult = _info.RequestResult;
            var  enumFlagsType = _info.SystemEvents;

            AudioStateType audioState = AudioStateType.Unknown;

            switch ((ESystemEvents)enumFlagsType)
            {
            case ESystemEvents.TriggerExecuted:
            {
                audioState = AudioStateType.TriggerStarted;
                break;
            }

            case ESystemEvents.TriggerFinished:
            {
                audioState = AudioStateType.TriggerEnded;
                break;
            }
            }
            string triggerName = GetTriggerName(ctrlId);

            if (triggerName != null)
            {
                Audio.ManagedAudioStateListenerDelegate audioStateListenerDelegate = AudioManager.GetAudioStateListener(triggerName);
                audioStateListenerDelegate?.Invoke(audioState, triggerName);
            }
        }
        private void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                _info.Dispose();
                _info = null;
                _requestListenersDelegates.Clear();
                _requestListenersDelegates = null;
                _indexTriggerIdToName.Clear();
                _indexTriggerIdToName = null;
                _triggerByName.Clear();
                _triggerByName = null;
            }

            //remove listener from c++
            IntPtr fnPtr = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(_requestListener);

            NativeAudioSystem.RemoveAudioRequestListener(fnPtr);
            _requestListener = null;

            _isDisposed = true;
        }
Esempio n. 3
0
        private void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                _info.Dispose();
                _info = null;
                _requestListenersDelegates.Clear();
                _requestListenersDelegates = null;
                _indexTriggerIdToName.Clear();
                _indexTriggerIdToName = null;
                _triggerByName.Clear();
                _triggerByName = null;
            }

            RemoveListener();

            _isDisposed = true;
        }