From 78f946a3ec4533352659568bbcbcfbf70f5862d0 Mon Sep 17 00:00:00 2001 From: Sypwn <9245957+Sypwn@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:32:09 -0500 Subject: [PATCH 1/2] Made IPropertyDictionary public, including CoreAudioDevice accessor --- .../CoreAudioDevice.Internal.cs | 9 --------- AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs | 9 +++++++++ .../Internal/IPropertyDictionary.cs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.Internal.cs b/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.Internal.cs index f0bf4a2..7820129 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.Internal.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.Internal.cs @@ -51,15 +51,6 @@ public sealed partial class CoreAudioDevice private ThreadLocal _audioMeterInformation; private IntPtr _audioMeterInformationPtr; - private IPropertyDictionary Properties - { - get - { - ThrowIfDisposed(); - return _properties; - } - } - /// /// Audio Meter Information - Future support /// diff --git a/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs b/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs index fde43f1..82c23d5 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/CoreAudioDevice.cs @@ -58,6 +58,15 @@ private IMultimediaDevice Device } } + public IPropertyDictionary Properties + { + get + { + ThrowIfDisposed(); + return _properties; + } + } + /// /// Unique identifier for this device /// diff --git a/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs b/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs index ad1484e..e5c1960 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs @@ -2,7 +2,7 @@ namespace AudioSwitcher.AudioApi.CoreAudio { - internal interface IPropertyDictionary : IDisposable + public interface IPropertyDictionary : IDisposable { AccessMode Mode { get; } @@ -14,7 +14,7 @@ internal interface IPropertyDictionary : IDisposable } [Flags] - internal enum AccessMode + public enum AccessMode { Read, Write, From 99c9be8d7c3be3efd87a376ad988450fce5fa4c8 Mon Sep 17 00:00:00 2001 From: Sypwn <9245957+Sypwn@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:18:48 -0500 Subject: [PATCH 2/2] Add IEnumerable to IPropertyDictionary --- .../Internal/CachedPropertyDictionary.cs | 10 ++++++++++ .../Internal/IPropertyDictionary.cs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/AudioSwitcher.AudioApi.CoreAudio/Internal/CachedPropertyDictionary.cs b/AudioSwitcher.AudioApi.CoreAudio/Internal/CachedPropertyDictionary.cs index f17cd75..9a3c9b6 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Internal/CachedPropertyDictionary.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Internal/CachedPropertyDictionary.cs @@ -127,5 +127,15 @@ public void SetValue(PropertyKey key, object value) Marshal.ThrowExceptionForHR(_propertyStoreInteface.SetValue(ref key, ref value)); _propertyStoreInteface.Commit(); } + + public IEnumerator> GetEnumerator() + { + return _properties.GetEnumerator(); + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } } } \ No newline at end of file diff --git a/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs b/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs index e5c1960..f7dc7f6 100644 --- a/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs +++ b/AudioSwitcher.AudioApi.CoreAudio/Internal/IPropertyDictionary.cs @@ -1,8 +1,9 @@ using System; +using System.Collections.Generic; namespace AudioSwitcher.AudioApi.CoreAudio { - public interface IPropertyDictionary : IDisposable + public interface IPropertyDictionary : IDisposable, IEnumerable> { AccessMode Mode { get; }