diff --git a/AudioSwitcher.AudioApi.CoreAudio.Tests/DeviceTests.cs b/AudioSwitcher.AudioApi.CoreAudio.Tests/DeviceTests.cs index 5724936..0ab5f6b 100644 --- a/AudioSwitcher.AudioApi.CoreAudio.Tests/DeviceTests.cs +++ b/AudioSwitcher.AudioApi.CoreAudio.Tests/DeviceTests.cs @@ -44,6 +44,22 @@ public void Device_Set_Volume_2() } + [Fact] + public void Device_Set_Volume_Negative_Is_Zero() + { + using (var controller = CreateTestController()) + { + var currentVolume = controller.DefaultPlaybackDevice.Volume; + + controller.DefaultPlaybackDevice.Volume = -5; + + Assert.Equal(0, (int)controller.DefaultPlaybackDevice.Volume); + + controller.DefaultPlaybackDevice.Volume = currentVolume; + } + + } + [Fact] public async Task Device_Set_Volume_Async() { @@ -76,6 +92,22 @@ public async Task Device_Set_Volume_Async_2() } + [Fact] + public async Task Device_Set_Volume_Async_Negative_Is_Zero() + { + using (var controller = CreateTestController()) + { + var currentVolume = controller.DefaultPlaybackDevice.Volume; + + await controller.DefaultPlaybackDevice.SetVolumeAsync(-5); + + Assert.Equal(0, (int)controller.DefaultPlaybackDevice.Volume); + + await controller.DefaultPlaybackDevice.SetVolumeAsync(currentVolume); + } + + } + [Fact] public void Device_Set_Default() { @@ -191,28 +223,26 @@ public async Task Device_Set_Default_Communications_Async_Returns_In_Order() { var order = new ConcurrentQueue(); var device = controller.DefaultPlaybackCommunicationsDevice; + var current = 1; var t1 = device.SetAsDefaultCommunicationsAsync().ContinueWith(x => { - order.Enqueue(1); + order.Enqueue(current++); }); - await Task.Delay(5); var t2 = device.SetAsDefaultCommunicationsAsync().ContinueWith(x => { - order.Enqueue(2); + order.Enqueue(current++); }); - await Task.Delay(5); var t3 = device.SetAsDefaultCommunicationsAsync().ContinueWith(x => { - order.Enqueue(3); + order.Enqueue(current++); }); - await Task.Delay(5); var t4 = device.SetAsDefaultCommunicationsAsync().ContinueWith(x => { - order.Enqueue(4); + order.Enqueue(current++); }); await Task.WhenAll(t1, t2, t3, t4); diff --git a/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs b/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs index 83342b8..df67f92 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs @@ -14,7 +14,7 @@ namespace AudioSwitcher.AudioApi.CoreAudio { public sealed partial class CoreAudioDevice : Device { - private const int DEFAULT_COM_TIMEOUT = 500; + private const int DefaultComTimeout = 500; private static readonly Dictionary> PropertykeyToPropertyMap = new Dictionary> { @@ -154,8 +154,13 @@ public override double Volume if (AudioEndpointVolume == null) return; - AudioEndpointVolume.MasterVolumeLevelScalar = NormailizeVolume(value); - _volumeResetEvent.Wait(DEFAULT_COM_TIMEOUT); + var normalizedVolume = NormalizeVolume(value); + + if (Math.Abs(_volume - normalizedVolume) < 0.1) + return; + + AudioEndpointVolume.MasterVolumeLevelScalar = normalizedVolume; + _volumeResetEvent.Wait(DefaultComTimeout); } } @@ -265,7 +270,7 @@ public override bool Mute(bool mute) return true; AudioEndpointVolume.Mute = mute; - _muteChangedResetEvent.Wait(DEFAULT_COM_TIMEOUT); + _muteChangedResetEvent.Wait(DefaultComTimeout); return _isMuted; } @@ -279,26 +284,28 @@ public override async Task MuteAsync(bool mute) return true; AudioEndpointVolume.Mute = mute; - await _muteChangedResetEvent.WaitAsync(DEFAULT_COM_TIMEOUT); + await _muteChangedResetEvent.WaitAsync(DefaultComTimeout); return _isMuted; } public override async Task SetVolumeAsync(double volume) { - if (Math.Abs(_volume - volume) < 0.1) + var normalizedVolume = NormalizeVolume(volume); + + if (Math.Abs(_volume - normalizedVolume) < 0.1) return _volume; if (AudioEndpointVolume == null) return -1; - AudioEndpointVolume.MasterVolumeLevelScalar = NormailizeVolume(volume); - await _volumeResetEvent.WaitAsync(DEFAULT_COM_TIMEOUT); + AudioEndpointVolume.MasterVolumeLevelScalar = normalizedVolume; + await _volumeResetEvent.WaitAsync(DefaultComTimeout); return _volume; } - private static float NormailizeVolume(double volume) + private static float NormalizeVolume(double volume) { if (volume <= 0) volume = 0; @@ -313,7 +320,7 @@ private static float NormailizeVolume(double volume) public override bool SetAsDefault() { var cts = new CancellationTokenSource(); - cts.CancelAfter(DEFAULT_COM_TIMEOUT); + cts.CancelAfter(DefaultComTimeout); return SetAsDefault(cts.Token); } @@ -351,7 +358,7 @@ public override bool SetAsDefault(CancellationToken cancellationToken) public override Task SetAsDefaultAsync() { var cts = new CancellationTokenSource(); - cts.CancelAfter(DEFAULT_COM_TIMEOUT); + cts.CancelAfter(DefaultComTimeout); return SetAsDefaultAsync(cts.Token); } @@ -392,7 +399,7 @@ public override async Task SetAsDefaultAsync(CancellationToken cancellatio public override bool SetAsDefaultCommunications() { var cts = new CancellationTokenSource(); - cts.CancelAfter(DEFAULT_COM_TIMEOUT); + cts.CancelAfter(DefaultComTimeout); return SetAsDefaultCommunications(cts.Token); } @@ -400,7 +407,7 @@ public override bool SetAsDefaultCommunications() public override Task SetAsDefaultCommunicationsAsync() { var cts = new CancellationTokenSource(); - cts.CancelAfter(DEFAULT_COM_TIMEOUT); + cts.CancelAfter(DefaultComTimeout); return SetAsDefaultCommunicationsAsync(cts.Token); } diff --git a/AudioSwitcher.AudioApi.CoreAudio/Extensions.cs b/AudioSwitcher.AudioApi.CoreAudio/Extensions.cs index 900b2bf..3779e95 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Extensions.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Extensions.cs @@ -7,7 +7,7 @@ namespace AudioSwitcher.AudioApi.CoreAudio { public static class Extensions { - private const string GUID_REGEX = + private const string GuidRegex = @"([a-fA-F0-9]{8}[-][a-fA-F0-9]{4}[-][a-fA-F0-9]{4}[-][a-fA-F0-9]{4}[-][a-fA-F0-9]{12})"; internal static EDataFlow AsEDataFlow(this DeviceType type) @@ -110,7 +110,7 @@ internal static Role AsRole(this ERole role) internal static IEnumerable ExtractGuids(this string str) { - var r = new Regex(GUID_REGEX); + var r = new Regex(GuidRegex); var matches = r.Matches(str); if (matches.Count == 0) diff --git a/AudioSwitcher.AudioApi.CoreAudio/Internal/PolicyConfig.cs b/AudioSwitcher.AudioApi.CoreAudio/Internal/PolicyConfig.cs index 22d3417..54dad29 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Internal/PolicyConfig.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Internal/PolicyConfig.cs @@ -36,8 +36,6 @@ public static void SetDefaultEndpoint(string devId, ERole eRole) { if (policyConfig != null && Marshal.IsComObject(policyConfig)) Marshal.FinalReleaseComObject(policyConfig); - - GC.Collect(); } } } diff --git a/AudioSwitcher.AudioApi.CoreAudio/Tasks/Deque.cs b/AudioSwitcher.AudioApi.CoreAudio/Tasks/Deque.cs index d1c8e00..80604a7 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Tasks/Deque.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Tasks/Deque.cs @@ -21,12 +21,12 @@ internal sealed class Deque : IList, System.Collections.IList /// /// The circular buffer that holds the view. /// - private T[] buffer; + private T[] _buffer; /// - /// The offset into where the view begins. + /// The offset into where the view begins. /// - private int offset; + private int _offset; /// /// Initializes a new instance of the class with the specified capacity. @@ -36,7 +36,7 @@ public Deque(int capacity) { if (capacity < 1) throw new ArgumentOutOfRangeException(nameof(capacity), "Capacity must be greater than 0."); - buffer = new T[capacity]; + _buffer = new T[capacity]; } /// @@ -48,12 +48,12 @@ public Deque(IEnumerable collection) int count = collection.Count(); if (count > 0) { - buffer = new T[count]; + _buffer = new T[count]; DoInsertRange(0, collection, count); } else { - buffer = new T[DefaultCapacity]; + _buffer = new T[DefaultCapacity]; } } @@ -384,9 +384,9 @@ private static void CheckRangeArguments(int sourceLength, int offset, int count) private bool IsFull => Count == Capacity; /// - /// Gets a value indicating whether the buffer is "split" (meaning the beginning of the view is at a later index in than the end). + /// Gets a value indicating whether the buffer is "split" (meaning the beginning of the view is at a later index in than the end). /// - private bool IsSplit => offset > Capacity - Count; + private bool IsSplit => _offset > Capacity - Count; /// /// Gets or sets the capacity for this deque. This value must always be greater than zero, and this property cannot be set to a value less than . @@ -396,7 +396,7 @@ public int Capacity { get { - return buffer.Length; + return _buffer.Length; } set @@ -407,7 +407,7 @@ public int Capacity if (value < Count) throw new InvalidOperationException("Capacity cannot be set to a value less than Count"); - if (value == buffer.Length) + if (value == _buffer.Length) return; // Create the new buffer and copy our existing range. @@ -415,19 +415,19 @@ public int Capacity if (IsSplit) { // The existing buffer is split, so we have to copy it in parts - int length = Capacity - offset; - Array.Copy(buffer, offset, newBuffer, 0, length); - Array.Copy(buffer, 0, newBuffer, length, Count - length); + int length = Capacity - _offset; + Array.Copy(_buffer, _offset, newBuffer, 0, length); + Array.Copy(_buffer, 0, newBuffer, length, Count - length); } else { // The existing buffer is whole - Array.Copy(buffer, offset, newBuffer, 0, Count); + Array.Copy(_buffer, _offset, newBuffer, 0, Count); } // Set up to use the new buffer. - buffer = newBuffer; - offset = 0; + _buffer = newBuffer; + _offset = 0; } } @@ -444,7 +444,7 @@ public int Capacity /// The buffer index. private int DequeIndexToBufferIndex(int index) { - return (index + offset) % Capacity; + return (index + _offset) % Capacity; } /// @@ -454,7 +454,7 @@ private int DequeIndexToBufferIndex(int index) /// The element at the specified index. private T DoGetItem(int index) { - return buffer[DequeIndexToBufferIndex(index)]; + return _buffer[DequeIndexToBufferIndex(index)]; } /// @@ -464,7 +464,7 @@ private T DoGetItem(int index) /// The element to store in the list. private void DoSetItem(int index, T item) { - buffer[DequeIndexToBufferIndex(index)] = item; + _buffer[DequeIndexToBufferIndex(index)] = item; } /// @@ -511,29 +511,29 @@ private void DoRemoveAt(int index) } /// - /// Increments by using modulo- arithmetic. + /// Increments by using modulo- arithmetic. /// - /// The value by which to increase . May not be negative. - /// The value of after it was incremented. + /// The value by which to increase . May not be negative. + /// The value of after it was incremented. private int PostIncrement(int value) { - int ret = offset; - offset += value; - offset %= Capacity; + int ret = _offset; + _offset += value; + _offset %= Capacity; return ret; } /// - /// Decrements by using modulo- arithmetic. + /// Decrements by using modulo- arithmetic. /// - /// The value by which to reduce . May not be negative or greater than . - /// The value of before it was decremented. + /// The value by which to reduce . May not be negative or greater than . + /// The value of before it was decremented. private int PreDecrement(int value) { - offset -= value; - if (offset < 0) - offset += Capacity; - return offset; + _offset -= value; + if (_offset < 0) + _offset += Capacity; + return _offset; } /// @@ -542,7 +542,7 @@ private int PreDecrement(int value) /// The element to insert. private void DoAddToBack(T value) { - buffer[DequeIndexToBufferIndex(Count)] = value; + _buffer[DequeIndexToBufferIndex(Count)] = value; ++Count; } @@ -552,7 +552,7 @@ private void DoAddToBack(T value) /// The element to insert. private void DoAddToFront(T value) { - buffer[PreDecrement(1)] = value; + _buffer[PreDecrement(1)] = value; ++Count; } @@ -562,7 +562,7 @@ private void DoAddToFront(T value) /// The former last element. private T DoRemoveFromBack() { - T ret = buffer[DequeIndexToBufferIndex(Count - 1)]; + T ret = _buffer[DequeIndexToBufferIndex(Count - 1)]; --Count; return ret; } @@ -574,7 +574,7 @@ private T DoRemoveFromBack() private T DoRemoveFromFront() { --Count; - return buffer[PostIncrement(1)]; + return _buffer[PostIncrement(1)]; } /// @@ -596,7 +596,7 @@ private void DoInsertRange(int index, IEnumerable collection, int collectionC int copyCount = index; int writeIndex = Capacity - collectionCount; for (int j = 0; j != copyCount; ++j) - buffer[DequeIndexToBufferIndex(writeIndex + j)] = buffer[DequeIndexToBufferIndex(j)]; + _buffer[DequeIndexToBufferIndex(writeIndex + j)] = _buffer[DequeIndexToBufferIndex(j)]; // Rotate to the new view PreDecrement(collectionCount); @@ -609,14 +609,14 @@ private void DoInsertRange(int index, IEnumerable collection, int collectionC int copyCount = Count - index; int writeIndex = index + collectionCount; for (int j = copyCount - 1; j != -1; --j) - buffer[DequeIndexToBufferIndex(writeIndex + j)] = buffer[DequeIndexToBufferIndex(index + j)]; + _buffer[DequeIndexToBufferIndex(writeIndex + j)] = _buffer[DequeIndexToBufferIndex(index + j)]; } // Copy new items into place int i = index; foreach (T item in collection) { - buffer[DequeIndexToBufferIndex(i)] = item; + _buffer[DequeIndexToBufferIndex(i)] = item; ++i; } @@ -653,7 +653,7 @@ private void DoRemoveRange(int index, int collectionCount) int copyCount = index; int writeIndex = collectionCount; for (int j = copyCount - 1; j != -1; --j) - buffer[DequeIndexToBufferIndex(writeIndex + j)] = buffer[DequeIndexToBufferIndex(j)]; + _buffer[DequeIndexToBufferIndex(writeIndex + j)] = _buffer[DequeIndexToBufferIndex(j)]; // Rotate to new view PostIncrement(collectionCount); @@ -666,7 +666,7 @@ private void DoRemoveRange(int index, int collectionCount) int copyCount = Count - collectionCount - index; int readIndex = index + collectionCount; for (int j = 0; j != copyCount; ++j) - buffer[DequeIndexToBufferIndex(index + j)] = buffer[DequeIndexToBufferIndex(readIndex + j)]; + _buffer[DequeIndexToBufferIndex(index + j)] = _buffer[DequeIndexToBufferIndex(readIndex + j)]; } // Adjust valid count @@ -779,18 +779,18 @@ public T RemoveFromFront() /// public void Clear() { - offset = 0; + _offset = 0; Count = 0; } [DebuggerNonUserCode] private sealed class DebugView { - private readonly Deque deque; + private readonly Deque _deque; public DebugView(Deque deque) { - this.deque = deque; + this._deque = deque; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] @@ -798,8 +798,8 @@ public T[] Items { get { - var array = new T[deque.Count]; - ((ICollection)deque).CopyTo(array, 0); + var array = new T[_deque.Count]; + ((ICollection)_deque).CopyTo(array, 0); return array; } } diff --git a/AudioSwitcher.AudioApi.CoreAudio/Tasks/TaskConstants.cs b/AudioSwitcher.AudioApi.CoreAudio/Tasks/TaskConstants.cs index 0739076..5d94a57 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Tasks/TaskConstants.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Tasks/TaskConstants.cs @@ -8,7 +8,7 @@ namespace Nito.AsyncEx public static class TaskConstants { private static readonly Task booleanTrue = Task.FromResult(true); - private static readonly Task intNegativeOne = Task.FromResult(-1); + private static readonly Task IntNegativeOne = Task.FromResult(-1); /// /// A task that has been completed with the value true. @@ -28,7 +28,7 @@ public static class TaskConstants /// /// A task that has been completed with the value -1. /// - public static Task Int32NegativeOne => intNegativeOne; + public static Task Int32NegativeOne => IntNegativeOne; /// /// A that has been completed. diff --git a/AudioSwitcher.AudioApi.CoreAudio/Threading/ComThread.cs b/AudioSwitcher.AudioApi.CoreAudio/Threading/ComThread.cs index 9637cee..4ca372d 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Threading/ComThread.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Threading/ComThread.cs @@ -6,11 +6,11 @@ namespace AudioSwitcher.AudioApi.CoreAudio.Threading { internal static class ComThread { - private static readonly ComTaskScheduler COM_SCHEDULER = new ComTaskScheduler(); + private static readonly ComTaskScheduler ComScheduler = new ComTaskScheduler(); private static bool InvokeRequired => Thread.CurrentThread.ManagedThreadId != Scheduler.ThreadId; - private static ComTaskScheduler Scheduler => COM_SCHEDULER; + private static ComTaskScheduler Scheduler => ComScheduler; /// /// Asserts that the execution following this statement is running on the ComThreads @@ -35,7 +35,7 @@ public static void Invoke(Action action) public static Task BeginInvoke(Action action) { - return Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, COM_SCHEDULER); + return Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, ComScheduler); } public static T Invoke(Func func) @@ -48,7 +48,7 @@ public static T Invoke(Func func) public static Task BeginInvoke(Func func) { - return Task.Factory.StartNew(func, CancellationToken.None, TaskCreationOptions.None, COM_SCHEDULER); + return Task.Factory.StartNew(func, CancellationToken.None, TaskCreationOptions.None, ComScheduler); } } } \ No newline at end of file diff --git a/AudioSwitcher.AudioApi.Hooking/EntryPoint.cs b/AudioSwitcher.AudioApi.Hooking/EntryPoint.cs index f05f61a..6219e11 100644 --- a/AudioSwitcher.AudioApi.Hooking/EntryPoint.cs +++ b/AudioSwitcher.AudioApi.Hooking/EntryPoint.cs @@ -12,11 +12,11 @@ public sealed class EntryPoint : IEntryPoint [return: MarshalAs(UnmanagedType.U4)] public delegate int DGetDefaultAudioEndpoint(IMultimediaDeviceEnumerator self, DataFlow dataFlow, Role role, out IntPtr ppEndpoint); - private readonly RemoteInterface Interface; + private readonly RemoteInterface _interface; public EntryPoint(RemoteHooking.IContext inContext, string inChannelName) { - Interface = RemoteHooking.IpcConnectClient(inChannelName); + _interface = RemoteHooking.IpcConnectClient(inChannelName); } public void Run(RemoteHooking.IContext inContext, string inChannelName) @@ -35,28 +35,28 @@ public void Run(RemoteHooking.IContext inContext, string inChannelName) Thread.Sleep(50); //Signal the hook installed, and get the response from the server - if (!Interface.HookInstalled()) + if (!_interface.HookInstalled()) return; } catch (Exception e) { - ReportError(Interface, e); + ReportError(_interface, e); return; } try { - while (!Interface.CanUnload()) + while (!_interface.CanUnload()) { Thread.Sleep(200); } - Interface.HookUninstalled(RemoteHooking.GetCurrentProcessId()); + _interface.HookUninstalled(RemoteHooking.GetCurrentProcessId()); } catch (Exception e) { - ReportError(Interface, e); + ReportError(_interface, e); } } @@ -65,10 +65,10 @@ private static int GetDefaultAudioEndpoint(IMultimediaDeviceEnumerator self, Dat { var entryPoint = HookRuntimeInfo.Callback as EntryPoint; - if (entryPoint == null || entryPoint.Interface == null) + if (entryPoint == null || entryPoint._interface == null) return self.GetDefaultAudioEndpoint(dataflow, role, out ppendpoint); - var remoteInterface = entryPoint.Interface; + var remoteInterface = entryPoint._interface; try { diff --git a/AudioSwitcher.AudioApi/AudioController.Generic.cs b/AudioSwitcher.AudioApi/AudioController.Generic.cs index 09c2bc0..0b74ae4 100644 --- a/AudioSwitcher.AudioApi/AudioController.Generic.cs +++ b/AudioSwitcher.AudioApi/AudioController.Generic.cs @@ -9,7 +9,7 @@ namespace AudioSwitcher.AudioApi public abstract class AudioController : IAudioController where T : class, IDevice { - private const DeviceState DEFAULT_DEVICE_STATE_FILTER = DeviceState.Active | DeviceState.Unplugged | DeviceState.Disabled; + private const DeviceState DefaultDeviceStateFilter = DeviceState.Active | DeviceState.Unplugged | DeviceState.Disabled; private readonly Broadcaster _audioDeviceChanged; @@ -38,7 +38,7 @@ protected AudioController() public virtual T GetDevice(Guid id) { - return GetDevice(id, DEFAULT_DEVICE_STATE_FILTER); + return GetDevice(id, DefaultDeviceStateFilter); } public virtual Task GetDeviceAsync(Guid id) @@ -62,7 +62,7 @@ public virtual Task GetDefaultDeviceAsync(DeviceType deviceType, Role role) public virtual IEnumerable GetDevices() { - return GetDevices(DEFAULT_DEVICE_STATE_FILTER); + return GetDevices(DefaultDeviceStateFilter); } public virtual Task> GetDevicesAsync() @@ -77,12 +77,12 @@ public virtual Task> GetDevicesAsync(DeviceState state) public IEnumerable GetDevices(DeviceType deviceType) { - return GetDevices(deviceType, DEFAULT_DEVICE_STATE_FILTER); + return GetDevices(deviceType, DefaultDeviceStateFilter); } public Task> GetDevicesAsync(DeviceType deviceType) { - return GetDevicesAsync(deviceType, DEFAULT_DEVICE_STATE_FILTER); + return GetDevicesAsync(deviceType, DefaultDeviceStateFilter); } IEnumerable IAudioController.GetDevices(DeviceType deviceType) @@ -109,7 +109,7 @@ public virtual Task> GetDevicesAsync(DeviceType deviceType, Devic public virtual IEnumerable GetPlaybackDevices() { - return GetPlaybackDevices(DEFAULT_DEVICE_STATE_FILTER); + return GetPlaybackDevices(DefaultDeviceStateFilter); } public virtual IEnumerable GetPlaybackDevices(DeviceState state) @@ -119,7 +119,7 @@ public virtual IEnumerable GetPlaybackDevices(DeviceState state) public virtual Task> GetPlaybackDevicesAsync() { - return GetPlaybackDevicesAsync(DEFAULT_DEVICE_STATE_FILTER); + return GetPlaybackDevicesAsync(DefaultDeviceStateFilter); } public virtual Task> GetPlaybackDevicesAsync(DeviceState deviceState) @@ -129,12 +129,12 @@ public virtual Task> GetPlaybackDevicesAsync(DeviceState deviceSt public virtual IEnumerable GetCaptureDevices() { - return GetCaptureDevices(DEFAULT_DEVICE_STATE_FILTER); + return GetCaptureDevices(DefaultDeviceStateFilter); } public virtual Task> GetCaptureDevicesAsync() { - return Task.FromResult(GetCaptureDevices(DEFAULT_DEVICE_STATE_FILTER)); + return Task.FromResult(GetCaptureDevices(DefaultDeviceStateFilter)); } public virtual IEnumerable GetCaptureDevices(DeviceState state) diff --git a/AudioSwitcher.AudioApi/AudioController.cs b/AudioSwitcher.AudioApi/AudioController.cs index 63a82e1..111ddcd 100644 --- a/AudioSwitcher.AudioApi/AudioController.cs +++ b/AudioSwitcher.AudioApi/AudioController.cs @@ -7,7 +7,7 @@ namespace AudioSwitcher.AudioApi { public abstract class AudioController : IAudioController { - protected const DeviceState DEFAULT_DEVICE_STATE_FILTER = + protected const DeviceState DefaultDeviceStateFilter = DeviceState.Active | DeviceState.Unplugged | DeviceState.Disabled; private readonly AsyncBroadcaster _audioDeviceChanged; @@ -50,7 +50,7 @@ public virtual Task GetDefaultDeviceAsync(DeviceType deviceType, Role r public virtual IEnumerable GetDevices() { - return GetDevices(DEFAULT_DEVICE_STATE_FILTER); + return GetDevices(DefaultDeviceStateFilter); } public virtual Task> GetDevicesAsync() @@ -65,12 +65,12 @@ public virtual Task> GetDevicesAsync(DeviceState state) public IEnumerable GetDevices(DeviceType deviceType) { - return GetDevices(deviceType, DEFAULT_DEVICE_STATE_FILTER); + return GetDevices(deviceType, DefaultDeviceStateFilter); } public Task> GetDevicesAsync(DeviceType deviceType) { - return GetDevicesAsync(deviceType, DEFAULT_DEVICE_STATE_FILTER); + return GetDevicesAsync(deviceType, DefaultDeviceStateFilter); } public virtual IEnumerable GetDevices(DeviceState state)