forked from naudio/NAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented classes for some missing interfaces needed to navigate de…
…vice topology
- Loading branch information
Showing
19 changed files
with
893 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using NAudio.CoreAudioApi.Interfaces; | ||
using NAudio.Wasapi.CoreAudioApi.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi | ||
{ | ||
public class AudioMute | ||
{ | ||
private IAudioMute audioMuteInterface; | ||
internal AudioMute(IAudioMute audioMute) | ||
{ | ||
audioMuteInterface = audioMute; | ||
} | ||
|
||
public bool IsMuted | ||
{ | ||
get | ||
{ | ||
audioMuteInterface.GetMute(out var result); | ||
return result; | ||
} | ||
set | ||
{ | ||
var guid = Guid.Empty; | ||
audioMuteInterface.SetMute(value, guid); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using NAudio.CoreAudioApi.Interfaces; | ||
using NAudio.Wasapi.CoreAudioApi.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NAudio.Wasapi.CoreAudioApi | ||
{ | ||
public class AudioVolumeLevel | ||
{ | ||
private readonly IAudioVolumeLevel audioVolumeLevelInterface; | ||
private bool isLevelRangeRead = false; | ||
private float minLevelDb, maxLevelDb, stepping; | ||
|
||
internal AudioVolumeLevel(IAudioVolumeLevel audioVolumeLevel) | ||
{ | ||
audioVolumeLevelInterface = audioVolumeLevel; | ||
} | ||
|
||
public uint ChannelCount | ||
{ | ||
get | ||
{ | ||
audioVolumeLevelInterface.GetChannelCount(out uint result); | ||
return result; | ||
} | ||
} | ||
|
||
public void GetLevelRange(uint channel, out float minLevelDb, out float maxLevelDb, out float stepping) | ||
{ | ||
audioVolumeLevelInterface.GetLevelRange(channel, out minLevelDb, out maxLevelDb, out stepping); | ||
} | ||
|
||
public float GetLevel(uint channel) | ||
{ | ||
audioVolumeLevelInterface.GetLevel(channel, out float result); | ||
return result; | ||
} | ||
|
||
public void SetLevel(uint channel, float value) | ||
{ | ||
var guid = Guid.Empty; | ||
audioVolumeLevelInterface.SetLevel(channel, value, ref guid); | ||
} | ||
|
||
public void SetLevelUniform(float value) | ||
{ | ||
var guid = Guid.Empty; | ||
audioVolumeLevelInterface.SetLevelUniform(value, ref guid); | ||
} | ||
|
||
public void SetLevelAllChannel(float[] values, uint channels) | ||
{ | ||
var guid = Guid.Empty; | ||
audioVolumeLevelInterface.SetLevelAllChannel(values, channels, ref guid); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
NAudio.Wasapi/CoreAudioApi/Interfaces/IAudioAutoGainControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("85401FD4-6DE4-4b9d-9869-2D6753A82F3C"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IAudioAutoGainControl | ||
{ | ||
[PreserveSig] | ||
int GetEnabled( | ||
[Out, MarshalAs(UnmanagedType.Bool)] out bool enabled); | ||
|
||
[PreserveSig] | ||
int SetEnabled( | ||
[In, MarshalAs(UnmanagedType.Bool)] bool enabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IAudioMute | ||
{ | ||
[PreserveSig] | ||
int GetMute( | ||
[Out, MarshalAs(UnmanagedType.Bool)] out bool mute); | ||
|
||
[PreserveSig] | ||
int SetMute( | ||
[In, MarshalAs(UnmanagedType.Bool)] bool mute, | ||
[In] ref Guid eventContext); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
NAudio.Wasapi/CoreAudioApi/Interfaces/IAudioVolumeLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IAudioVolumeLevel : IPerChannelDbLevel | ||
{ | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
NAudio.Wasapi/CoreAudioApi/Interfaces/IControlChangeNotify.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.Wasapi.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("9c2c4058-23f5-41de-877a-df3af236a09e"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
interface IControlChangeNotify | ||
{ | ||
[PreserveSig] | ||
int OnNotify( | ||
[In] uint controlId, | ||
[In] IntPtr context); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
NAudio.Wasapi/CoreAudioApi/Interfaces/IControlInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("45d37c3f-5140-444a-ae24-400789f3cbf3"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
public interface IControlInterface | ||
{ | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
NAudio.Wasapi/CoreAudioApi/Interfaces/IKsJackDescription.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using NAudio.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("4509F757-2D46-4637-8E62-CE7DB944F57B"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IKsJackDescription | ||
{ | ||
int GetJackCount([Out] out uint jacks); | ||
int GetJackDescription([In] uint jack, [Out, MarshalAs(UnmanagedType.LPWStr)] out string description); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
/// <summary> | ||
/// Windows CoreAudio IPart interface | ||
/// Defined in devicetopology.h | ||
/// </summary> | ||
[Guid("AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IPart | ||
{ | ||
// Stub, Not implemented | ||
} | ||
} | ||
using NAudio.Wasapi.CoreAudioApi.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
/// <summary> | ||
/// Windows CoreAudio IPart interface | ||
/// Defined in devicetopology.h | ||
/// </summary> | ||
[Guid("AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IPart | ||
{ | ||
int GetName( | ||
[Out, MarshalAs(UnmanagedType.LPWStr)] out string name); | ||
|
||
int GetLocalId( | ||
[Out] out uint id); | ||
|
||
int GetGlobalId( | ||
[Out, MarshalAs(UnmanagedType.LPWStr)] out string id); | ||
|
||
int GetPartType( | ||
[Out] out PartTypeEnum partType); | ||
|
||
int GetSubType( | ||
out Guid subType); | ||
|
||
int GetControlInterfaceCount( | ||
[Out] out uint count); | ||
|
||
int GetControlInterface( | ||
[In] uint index, | ||
[Out, MarshalAs(UnmanagedType.IUnknown)] out IControlInterface controlInterface); | ||
|
||
[PreserveSig] | ||
int EnumPartsIncoming( | ||
[Out] out IPartsList parts); | ||
|
||
[PreserveSig] | ||
int EnumPartsOutgoing( | ||
[Out] out IPartsList parts); | ||
|
||
int GetTopologyObject( | ||
[Out] out object topologyObject); | ||
|
||
[PreserveSig] | ||
int Activate( | ||
[In] ClsCtx dwClsContext, | ||
[In] ref Guid refiid, | ||
[MarshalAs(UnmanagedType.IUnknown)] out object interfacePointer); | ||
|
||
int RegisterControlChangeCallback( | ||
[In] ref Guid refiid, | ||
[In] IControlChangeNotify notify); | ||
|
||
int UnregisterControlChangeCallback( | ||
[In] IControlChangeNotify notify); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
NAudio.Wasapi/CoreAudioApi/Interfaces/IPerChannelDbLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface IPerChannelDbLevel | ||
{ | ||
int GetChannelCount(out uint channels); | ||
int GetLevelRange(uint channel, out float minLevelDb, out float maxLevelDb, out float stepping); | ||
int GetLevel(uint channel, out float levelDb); | ||
int SetLevel(uint channel, float levelDb, ref Guid eventGuidContext); | ||
int SetLevelUniform(float levelDb, ref Guid eventGuidContext); | ||
int SetLevelAllChannel(float[] levelsDb, uint channels, ref Guid eventGuidContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
public enum PartTypeEnum | ||
{ | ||
Connector = 0, | ||
Subunit = 1, | ||
HardwarePeriphery = 2, | ||
SoftwareDriver = 3, | ||
Splitter = 4, | ||
Category = 5, | ||
Other = 6 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using NAudio.CoreAudioApi.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi | ||
{ | ||
public class KsJackDescription | ||
{ | ||
private readonly IKsJackDescription ksJackDescriptionInterface; | ||
|
||
internal KsJackDescription(IKsJackDescription ksJackDescription) | ||
{ | ||
ksJackDescriptionInterface = ksJackDescription; | ||
} | ||
|
||
public uint Count | ||
{ | ||
get | ||
{ | ||
ksJackDescriptionInterface.GetJackCount(out var result); | ||
return result; | ||
} | ||
} | ||
|
||
public string this[uint index] | ||
{ | ||
get | ||
{ | ||
ksJackDescriptionInterface.GetJackDescription(index, out var result); | ||
return result; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.