Beispiel #1
0
        internal static void ValidateState(AudioIOState curState, params AudioIOState[] desiredStates)
        {
            Debug.Assert(desiredStates.Length > 0);

            if (desiredStates.Contains(curState))
            {
                return;
            }

            throw new InvalidOperationException($"The audio is not in a valid state. " +
                                                $"Current State : { curState }, Valid State : { string.Join(", ", desiredStates) }.");
        }
Beispiel #2
0
        private void RegisterStateChangedCallback()
        {
            _stateChangedCallback = (IntPtr handle, int previous, int current, bool byPolicy, IntPtr _) =>
            {
                _state = (AudioIOState)current;

                StateChanged?.Invoke(this,
                                     new AudioIOStateChangedEventArgs((AudioIOState)previous, _state, byPolicy));
            };

            AudioIOUtil.ThrowIfError(
                AudioInput.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero));
        }
Beispiel #3
0
        private void RegisterStateChangedCallback()
        {
            _stateChangedCallback = (IntPtr handle, int previous, int current, bool byPolicy, IntPtr _) =>
            {
                _state = (AudioIOState)current;

                StateChanged?.Invoke(this,
                                     new AudioIOStateChangedEventArgs((AudioIOState)previous, _state, byPolicy));
            };

            AudioOutput.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero)
            .ThrowIfFailed("Failed to set state changed callback.");
        }
Beispiel #4
0
 internal AudioIOStateChangedEventArgs(AudioIOState previous, AudioIOState current, bool byPolicy)
 {
     Previous = previous;
     Current  = current;
     ByPolicy = byPolicy;
 }