using System; using System.Runtime.InteropServices; using Vanara.InteropServices; using static Vanara.PInvoke.AdvApi32; using static Vanara.PInvoke.Ole32; namespace Vanara.PInvoke { /// Functions, structures and constants from Windows Core Audio Api. public static partial class CoreAudio { /// Specifies the mapping of the two audio channels in a stereo jack to speaker positions. [PInvokeData("devicetopology.h", MSDNShortId = "4ee9fedf-4241-4678-b621-549a06e8949a")] [Flags] public enum ChannelMapping : uint { /// The front left SPEAKER_FRONT_LEFT = 0x1, /// The front right SPEAKER_FRONT_RIGHT = 0x2, /// The front center SPEAKER_FRONT_CENTER = 0x4, /// The low frequency SPEAKER_LOW_FREQUENCY = 0x8, /// The back left SPEAKER_BACK_LEFT = 0x10, /// The back right SPEAKER_BACK_RIGHT = 0x20, /// The front left of center SPEAKER_FRONT_LEFT_OF_CENTER = 0x40, /// The front right of center SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80, /// The back center SPEAKER_BACK_CENTER = 0x100, /// The side left SPEAKER_SIDE_LEFT = 0x200, /// The side right SPEAKER_SIDE_RIGHT = 0x400, /// The top center SPEAKER_TOP_CENTER = 0x800, /// The top front left SPEAKER_TOP_FRONT_LEFT = 0x1000, /// The top front center SPEAKER_TOP_FRONT_CENTER = 0x2000, /// The top front right SPEAKER_TOP_FRONT_RIGHT = 0x4000, /// The top back left SPEAKER_TOP_BACK_LEFT = 0x8000, /// The top back center SPEAKER_TOP_BACK_CENTER = 0x10000, /// The top back right SPEAKER_TOP_BACK_RIGHT = 0x20000, } /// The ConnectorType enumeration indicates the type of connection that a connector is part of. /// /// The IConnector::GetType method uses the constants defined in the ConnectorType enumeration. /// For more information about connector types, see Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/ne-devicetopology-connectortype typedef enum // __MIDL___MIDL_itf_devicetopology_0000_0000_0013 { Unknown_Connector, Physical_Internal, Physical_External, Software_IO, // Software_Fixed, Network } ConnectorType; [PInvokeData("devicetopology.h", MSDNShortId = "7171a880-2a3e-45aa-803d-26bf5e9e0365")] public enum ConnectorType { /// The connector is part of a connection of unknown type. Unknown_Connector, /// /// The connector is part of a physical connection to an auxiliary device that is installed inside the system chassis (for /// example, a connection to the analog output of an internal CD player, or to a built-in microphone or built-in speakers in a /// laptop computer). /// Physical_Internal, /// /// The connector is part of a physical connection to an external device. That is, the connector is a user-accessible jack that /// connects to a microphone, speakers, headphones, S/PDIF input or output device, or line input or output device. /// Physical_External, /// /// The connector is part of a software-configured I/O connection (typically a DMA channel) between system memory and an audio /// hardware device on an audio adapter. /// Software_IO, /// /// The connector is part of a permanent connection that is fixed and cannot be configured under software control. This type of /// connection is typically used to connect two audio hardware devices that reside on the same adapter. /// Software_Fixed, /// The connector is part of a connection to a network. Network, } /// The DataFlow enumeration indicates the data-flow direction of an audio stream through a connector. /// /// The IConnector::GetDataFlow method uses the constants defined in the DataFlow enumeration. /// /// The topology of a rendering or capture device on an audio adapter typically has one or more connectors with a data-flow /// direction of "In" through which audio data enters the device, and one or more connectors with a data-flow direction of "Out" /// through which audio data exits the device. For example, a typical rendering device on an adapter has a connector with data-flow /// direction "In" through which the Windows audio engine streams PCM data into the device. The same device has a connector with /// data-flow direction "Out" through which the device transmits an audio signal to speakers or headphones. /// /// /// The topology of a rendering endpoint device (for example, headphones) has a single connector with data-flow direction "In" /// through which audio data (in the form of an analog signal) enters the device. /// /// /// The topology of a capture endpoint device (for example, a microphone) has a single connector with data-flow direction "Out" /// through which audio data exits the device. /// /// For more information, see Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/ne-devicetopology-dataflow typedef enum // __MIDL___MIDL_itf_devicetopology_0000_0000_0011 { In, Out } DataFlow; [PInvokeData("devicetopology.h", MSDNShortId = "bdc2336c-5609-43f2-9b65-d8806f0fc63b")] public enum DataFlow { /// Input stream. The audio stream flows into the device through the connector. In, /// Output stream. The audio stream flows out of the device through the connector. Out, } /// Specifies the physical connection type for this jack. [PInvokeData("Ksmedia.h", MSDNShortId = "303bc73a-fe47-499b-97b3-7c49a40e8cfa")] public enum EPcxConnectionType { /// Unknown eConnTypeUnknown, /// 3.5 mm minijack eConnType3Point5mm, /// 1/4-inch jack eConnTypeQuarter, /// ATAPI internal connector eConnTypeAtapiInternal, /// RCA jack eConnTypeRCA, /// Optical connector eConnTypeOptical, /// Generic digital connector eConnTypeOtherDigital, /// Generic analog connector eConnTypeOtherAnalog, /// Multichannel analog DIN connector eConnTypeMultichannelAnalogDIN, /// XLR connector eConnTypeXlrProfessional, /// RJ11 modem connector eConnTypeRJ11Modem, /// Connector combination eConnTypeCombination, } /// /// Specifies the general location of the jack. The value of this member is one of the EPcxGenLocation enumeration values shown in /// the following table. /// [PInvokeData("Ksmedia.h", MSDNShortId = "303bc73a-fe47-499b-97b3-7c49a40e8cfa")] public enum EPcxGenLocation { /// On primary chassis eGenLocPrimaryBox, /// Inside primary chassis eGenLocInternal, /// On separate chassis eGenLocSeparate, /// Other location eGenLocOther, /// EPcxGenLocation_enum_count } /// /// The geometric location of the jack. The value of this member is one of the EPcxGeoLocation enumeration values shown in the /// following table. /// [PInvokeData("Ksmedia.h", MSDNShortId = "303bc73a-fe47-499b-97b3-7c49a40e8cfa")] public enum EPcxGeoLocation { /// Rear eGeoLocRear = 0x1, /// Front eGeoLocFront, /// Left eGeoLocLeft, /// Right eGeoLocRight, /// Top eGeoLocTop, /// Bottom eGeoLocBottom, /// Rear slide-open or pull-open panel eGeoLocRearPanel, /// Riser card eGeoLocRiser, /// Inside lid of mobile computer eGeoLocInsideMobileLid, /// Drive bay eGeoLocDrivebay, /// HDMI connector eGeoLocHDMI, /// Outside lid of mobile computer eGeoLocOutsideMobileLid, /// ATAPI connector eGeoLocATAPI, /// Not applicable. See Remarks section. eGeoLocNotApplicable, /// eGeoLocReserved6, /// EPcxGeoLocation_enum_count } /// /// Specifies the type of port represented by the jack. The value of this member is one of the EPxcPortConnection enumeration values /// shown in the following table. /// [PInvokeData("Ksmedia.h", MSDNShortId = "303bc73a-fe47-499b-97b3-7c49a40e8cfa")] public enum EPxcPortConnection { /// Jack ePortConnJack, /// Slot for an integrated device ePortConnIntegratedDevice, /// Both a jack and a slot for an integrated device ePortConnBothIntegratedAndJack, /// Unknown ePortConnUnknown, } /// Indicates the capabilities of the jack. [PInvokeData("Ksmedia.h", MSDNShortId = "0db29870-20d0-459b-a531-3dea5d073183")] public enum JackCapabilities : uint { /// Jack supports jack presence detection. JACKDESC2_PRESENCE_DETECT_CAPABILITY = 0x00000001, /// Jack supports dynamic format change. JACKDESC2_DYNAMIC_FORMAT_CHANGE_CAPABILITY = 0x00000002, } /// /// The KSJACK_SINK_CONNECTIONTYPE enumeration defines constants that specify the type of connection. These values are used /// in the KSJACK_SINK_INFORMATION structure that stores information about an audio jack sink. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/ne-devicetopology-ksjack_sink_connectiontype typedef enum // __MIDL___MIDL_itf_devicetopology_0000_0000_0010 { KSJACK_SINK_CONNECTIONTYPE_HDMI, KSJACK_SINK_CONNECTIONTYPE_DISPLAYPORT } KSJACK_SINK_CONNECTIONTYPE; [PInvokeData("devicetopology.h", MSDNShortId = "a1a9b0cf-b1bf-49df-a976-62f44fcf70ae")] public enum KSJACK_SINK_CONNECTIONTYPE { /// High-Definition Multimedia Interface (HDMI) connection. KSJACK_SINK_CONNECTIONTYPE_HDMI, /// Display port. KSJACK_SINK_CONNECTIONTYPE_DISPLAYPORT, } /// /// The PartType enumeration defines constants that indicate whether a part in a device topology is a connector or subunit. /// /// /// /// The IPart::GetPartType method uses the constants defined in the PartType enumeration to indicate whether an IPart object /// represents a connector or a subunit. If an IPart object represents a connector, a client can query that that object for /// its IConnector interface. If an IPart object represents a subunit, a client can query that that object for its ISubunit interface. /// /// For more information about connectors and subunits, see Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/ne-devicetopology-parttype typedef enum // __MIDL___MIDL_itf_devicetopology_0000_0000_0012 { Connector, Subunit } PartType; [PInvokeData("devicetopology.h", MSDNShortId = "7374d6c6-c59e-4862-8b4c-bbe384ccc9d8")] public enum PartType { /// /// The part is a connector. A connector can represent an audio jack, an internal connection to an integrated endpoint device, /// or a software connection implemented through DMA transfers. For more information about connector types, see ConnectorType Enumeration. /// Connector, /// /// The part is a subunit. A subunit is an audio-processing node in a device topology. A subunit frequently has one or more /// hardware control parameters that can be set under program control. For example, an audio application can change the volume /// setting of a volume-control subunit. /// Subunit, } /// /// /// The IAudioAutoGainControl interface provides access to a hardware automatic gain control (AGC). The client obtains a /// reference to the IAudioAutoGainControl interface of a subunit by calling the IPart::Activate method with parameter refiid /// set to REFIID IID_IAudioAutoGainControl. The call to IPart::Activate succeeds only if the subunit supports the /// IAudioAutoGainControl interface. Only a subunit object that represents a hardware AGC function will support this interface. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioAutoGainControl interface provides /// convenient access to the KSPROPERTY_AUDIO_AGC property of a subunit that has a subtype GUID value of KSNODETYPE_AGC. To obtain /// the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, /// see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudioautogaincontrol [PInvokeData("devicetopology.h", MSDNShortId = "f21e27e6-f3a0-418a-ad2e-e3e104dd6da2")] [ComImport, Guid("85401FD4-6DE4-4b9d-9869-2D6753A82F3C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioAutoGainControl { /// The GetEnabled method gets the current state (enabled or disabled) of the AGC. /// /// A BOOL variable into which the method writes the current AGC state. If the state is TRUE, AGC is enabled. If /// FALSE, AGC is disabled. /// /// /// A disabled AGC operates in pass-through mode. In this mode, the audio stream passes through the AGC without modification. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudioautogaincontrol-getenabled HRESULT // GetEnabled( BOOL *pbEnabled ); [return: MarshalAs(UnmanagedType.Bool)] bool GetEnabled(); /// The SetEnabled method enables or disables the AGC. /// /// The new AGC state. If this parameter is TRUE (nonzero), the method enables AGC. If FALSE, it disables AGC. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetEnabled call changes the state of the AGC control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// /// If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values /// shown in the following table. /// /// /// /// Return code /// Description /// /// /// E_OUTOFMEMORY /// Out of memory. /// /// /// /// /// A disabled AGC control operates in pass-through mode. In this mode, the audio stream passes through the control without modification. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudioautogaincontrol-setenabled HRESULT // SetEnabled( BOOL bEnable, LPCGUID pguidEventContext ); void SetEnabled([In] [MarshalAs(UnmanagedType.Bool)] bool bEnable, [Optional] in Guid pguidEventContext); } /// /// The IAudioBass interface provides access to a hardware bass-level control. The client obtains a reference to the /// IAudioBass interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioBass. The call to IPart::Activate succeeds only if the subunit supports the IAudioBass interface. Only a /// subunit object that represents a hardware function for controlling the level of the bass frequencies in each channel will /// support this interface. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiobass [PInvokeData("devicetopology.h", MSDNShortId = "036ca996-8612-4905-9afa-a4c3b4624652")] [ComImport, Guid("A2B1A1D9-4DB3-425D-A2B2-BD335CB3E2E5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioBass : IPerChannelDbLevel { /// The GetChannelCount method gets the number of channels in the audio stream. /// A UINT variable into which the method writes the channel count (the number of channels in the audio stream). // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getchannelcount // HRESULT GetChannelCount( UINT *pcChannels ); new uint GetChannelCount(); /// The GetLevelRange method gets the range, in decibels, of the volume level of the specified channel. /// /// The number of the selected channel. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// Pointer to a float variable into which the method writes the minimum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the maximum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the stepping value between consecutive volume levels in the /// range *pfMinLevelDB to *pfMaxLevelDB. If the difference between the maximum and minimum volume levels is d decibels, and the /// range is divided into n steps (uniformly sized intervals), then the volume can have n + 1 discrete levels and the size of /// the step between consecutive levels is d / n decibels. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevelrange HRESULT // GetLevelRange( UINT nChannel, float *pfMinLevelDB, float *pfMaxLevelDB, float *pfStepping ); new void GetLevelRange([In] uint nChannel, out float pfMinLevelDB, out float pfMaxLevelDB, out float pfStepping); /// The GetLevel method gets the volume level, in decibels, of the specified channel. /// /// The channel number. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the number of /// channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// A float variable into which the method writes the volume level, in decibels, of the specified channel. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevel HRESULT // GetLevel( UINT nChannel, float *pfLevelDB ); new float GetLevel([In] uint nChannel); /// The SetLevel method sets the volume level, in decibels, of the specified channel. /// /// The number of the selected channel. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The new volume level in decibels. A positive value represents gain, and a negative value represents attenuation. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevel call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// /// If the caller specifies a value for fLevelDB that is an exact stepping value, the SetLevel method completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method will return either the value that was set, or one /// of the following values: /// /// /// /// If the set value was below the minimum, the GetLevel method returns the minimum value. /// /// /// If the set value was above the maximum, the GetLevel method returns the maximum value. /// /// /// /// If the set value was between two stepping values, the GetLevel method returns a value that could be the next stepping /// value above or the stepping value below the set value; the relative distances from the set value to the neighboring stepping /// values is unimportant. The value that the GetLevel method returns is whichever value has more of an impact on the /// signal path. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevel HRESULT // SetLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); new void SetLevel([In] uint nChannel, [In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelUniform method sets all channels in the audio stream to the same uniform volume level, in decibels. /// /// The new uniform level in decibels. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelUniform call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// If the specified uniform level is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports for a /// particular channel, the SetLevelUniform call clamps the value for that channel to the supported range and completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setleveluniform // HRESULT SetLevelUniform( float fLevelDB, LPCGUID pguidEventContext ); new void SetLevelUniform([In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelAllChannels method sets the volume levels, in decibels, of all the channels in the audio stream. /// /// /// Pointer to an array of volume levels. This parameter points to a caller-allocated float array into which the method /// writes the new volume levels, in decibels, for all the channels. The method writes the level for a particular channel into /// the array element whose index matches the channel number. If the audio stream contains n channels, the channels are numbered /// 0 to n– 1. To get the number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The number of elements in the aLevelsDB array. If this parameter does not match the number of channels in the audio stream, /// the method fails without modifying the aLevelsDB array. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelAllChannels call changes the state of the level control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// If the specified level value for any channel is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports /// for that channel, the SetLevelAllChannels call clamps the value to the supported range and completes successfully. A /// subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevelallchannels // HRESULT SetLevelAllChannels( float [] aLevelsDB, ULONG cChannels, LPCGUID pguidEventContext ); new void SetLevelAllChannels([In, MarshalAs(UnmanagedType.LPArray)] float[] aLevelsDB, [In] uint cChannels, [Optional] in Guid pguidEventContext); } /// /// /// The IAudioChannelConfig interface provides access to a hardware channel-configuration control. The client obtains a /// reference to the IAudioChannelConfig interface of a subunit by calling the IPart::Activate method with parameter refiid /// set to REFIID IID_IAudioChannelConfig. The call to IPart::Activate succeeds only if the subunit supports the /// IAudioChannelConfig interface. Only a subunit object that represents a hardware channel-configuration control will /// support this interface. /// /// /// A client of the IAudioChannelConfig interface programs a hardware channel-configuration control by writing a /// channel-configuration mask to the control. The mask specifies the assignment of audio channels to speakers. For more information /// about channel-configuration masks, see the following: /// /// /// /// The discussion of the KSPROPERTY_AUDIO_CHANNEL_CONFIG property in the Windows DDK documentation. /// /// /// /// The white paper titled "Audio Driver Support for Home Theater Speaker Configurations" at the Audio Device Technologies for /// Windows website. /// /// /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioChannelConfig interface provides /// convenient access to the KSPROPERTY_AUDIO_CHANNEL_CONFIG property of a subunit that has a subtype GUID value of /// KSNODETYPE_3D_EFFECTS, KSNODETYPE_DAC, KSNODETYPE_VOLUME, or KSNODETYPE_PROLOGIC_DECODER. To obtain the subtype GUID of a /// subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiochannelconfig [PInvokeData("devicetopology.h", MSDNShortId = "b8e54e9e-a6eb-46e6-a71c-ff498c7e8f47")] [ComImport, Guid("BB11C46F-EC28-493C-B88A-5DB88062CE98"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioChannelConfig { /// The SetChannelConfig method sets the channel-configuration mask in a channel-configuration control. /// The channel-configuration mask. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetChannelConfig call changes the state of the channel-configuration control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// For information about channel-configuration masks, see the discussion of the KSPROPERTY_AUDIO_CHANNEL_CONFIG property in the /// Windows DDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiochannelconfig-setchannelconfig // HRESULT SetChannelConfig( DWORD dwConfig, LPCGUID pguidEventContext ); void SetChannelConfig(uint dwConfig, [Optional] in Guid pguidEventContext); /// /// The GetChannelConfig method gets the current channel-configuration mask from a channel-configuration control. /// /// A DWORD variable into which the method writes the current channel-configuration mask value. /// /// For information about channel-configuration masks, see the discussion of the KSPROPERTY_AUDIO_CHANNEL_CONFIG property in the /// Windows DDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiochannelconfig-getchannelconfig // HRESULT GetChannelConfig( DWORD *pdwConfig ); uint GetChannelConfig(); } /// /// /// The IAudioInputSelector interface provides access to a hardware multiplexer control (input selector). The client obtains /// a reference to the IAudioInputSelector interface of a subunit by calling the IPart::Activate method with parameter refiid /// set to REFIID IID_IAudioInputSelector. The call to IPart::Activate succeeds only if the subunit supports the /// IAudioInputSelector interface. Only a subunit object that represents a hardware input selector will support this interface. /// /// /// Each input of an input selector is identified by the local ID of the part (a connector or subunit of a device topology) that has /// a direct link to the input. A local ID is a number that uniquely identifies a part among all the parts in a device topology. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioInputSelector interface provides /// convenient access to the KSPROPERTY_AUDIO_MUX_SOURCE property of a subunit that has a subtype GUID value of KSNODETYPE_MUX. To /// obtain the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node /// types, see the Windows DDK documentation. /// /// /// For a code example that uses the IAudioInputSelector interface, see the implementation of the SelectCaptureDevice /// function in Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudioinputselector [PInvokeData("devicetopology.h", MSDNShortId = "6f5ce9c0-39e4-4fab-910c-9a11b90fcde7")] [ComImport, Guid("4F03DC02-5E6E-4653-8F72-A030C123D598"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioInputSelector { /// /// The GetSelection method gets the local ID of the part that is connected to the selector input that is currently selected. /// /// /// Pointer to a UINT variable into which the method writes the local ID of the part that directly links to the currently /// selected selector input. /// /// /// A local ID is a number that uniquely identifies a part among all parts in a device topology. To obtain a pointer to the /// IPart interface of a part from its local ID, call the IDeviceTopology::GetPartById method. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudioinputselector-getselection HRESULT // GetSelection( UINT *pnIdSelected ); uint GetSelection(); /// The SetSelection method selects one of the inputs of the input selector. /// /// The new selector input. The caller should set this parameter to the local ID of a part that has a direct link to one of the /// selector inputs. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetSelection call changes the state of the input-selector control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// /// A local ID is a number that uniquely identifies a part among all parts in a device topology. To obtain the local ID of a /// part, call the IPart::GetLocalId method on the part object. /// /// /// For a code example that calls the SetSelection method, see the implementation of the SelectCaptureDevice function in /// Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudioinputselector-setselection HRESULT // SetSelection( UINT nIdSelect, LPCGUID pguidEventContext ); void SetSelection([In] uint nIdSelect, [Optional] in Guid pguidEventContext); } /// /// /// The IAudioLoudness interface provides access to a "loudness" compensation control. The client obtains a reference to the /// IAudioLoudness interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioLoudness. The call to IPart::Activate succeeds only if the subunit supports the IAudioLoudness /// interface. Only a subunit object that represents a hardware loudness control function will support this interface. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioLoudness interface provides convenient /// access to the KSPROPERTY_AUDIO_LOUDNESS property of a subunit that has a subtype GUID value of KSNODETYPE_LOUDNESS. To obtain /// the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, /// see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudioloudness [PInvokeData("devicetopology.h", MSDNShortId = "c182d6ae-c55b-4e3b-9639-7c2f2f7d826d")] [ComImport, Guid("7D8B1437-DD53-4350-9C1B-1EE2890BD938"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioLoudness { /// The GetEnabled method gets the current state (enabled or disabled) of the loudness control. /// /// A BOOL variable into which the method writes the current loudness state. If the state is TRUE, loudness is /// enabled. If FALSE, loudness is disabled. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudioloudness-getenabled HRESULT // GetEnabled( BOOL *pbEnabled ); [return: MarshalAs(UnmanagedType.Bool)] bool GetEnabled(); /// The SetEnabled method enables or disables the loudness control. /// /// The new loudness state. If bEnable is TRUE (nonzero), the method enables loudness. If FALSE, it disables loudness. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetEnabled call changes the state of the loudness control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudioloudness-setenabled HRESULT // SetEnabled( BOOL bEnable, LPCGUID pguidEventContext ); void SetEnabled([MarshalAs(UnmanagedType.Bool)] bool bEnable, [Optional] in Guid pguidEventContext); } /// /// /// The IAudioMidrange interface provides access to a hardware midrange-level control. The client obtains a reference to the /// IAudioMidrange interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioMidrange. The call to IPart::Activate succeeds only if the subunit supports the IAudioMidrange /// interface. Only a subunit object that represents a hardware function for controlling the level of the mid-range frequencies in /// each channel will support this interface. /// /// /// The IAudioMidrange interface provides per-channel controls for setting and getting the gain or attenuation level of the /// midrange frequencies in the audio stream. If a midrange-level hardware control can only attenuate the channels in the audio /// stream, then the maximum midrange level for any channel is 0 dB. If a midrange-level control can provide gain (amplification), /// then the maximum midrange level is greater than 0 dB. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioMidrange interface provides convenient /// access to the KSPROPERTY_AUDIO_MID property of a subunit that has a subtype GUID value of KSNODETYPE_TONE. To obtain the subtype /// GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, see the /// Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiomidrange [PInvokeData("devicetopology.h", MSDNShortId = "d2d93dba-1867-4c3a-9cd1-60842bf8311d")] [ComImport, Guid("5E54B6D7-B44B-40D9-9A9E-E691D9CE6EDF"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioMidrange : IPerChannelDbLevel { /// The GetChannelCount method gets the number of channels in the audio stream. /// A UINT variable into which the method writes the channel count (the number of channels in the audio stream). // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getchannelcount // HRESULT GetChannelCount( UINT *pcChannels ); new uint GetChannelCount(); /// The GetLevelRange method gets the range, in decibels, of the volume level of the specified channel. /// /// The number of the selected channel. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// Pointer to a float variable into which the method writes the minimum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the maximum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the stepping value between consecutive volume levels in the /// range *pfMinLevelDB to *pfMaxLevelDB. If the difference between the maximum and minimum volume levels is d decibels, and the /// range is divided into n steps (uniformly sized intervals), then the volume can have n + 1 discrete levels and the size of /// the step between consecutive levels is d / n decibels. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevelrange HRESULT // GetLevelRange( UINT nChannel, float *pfMinLevelDB, float *pfMaxLevelDB, float *pfStepping ); new void GetLevelRange([In] uint nChannel, out float pfMinLevelDB, out float pfMaxLevelDB, out float pfStepping); /// The GetLevel method gets the volume level, in decibels, of the specified channel. /// /// The channel number. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the number of /// channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// A float variable into which the method writes the volume level, in decibels, of the specified channel. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevel HRESULT // GetLevel( UINT nChannel, float *pfLevelDB ); new float GetLevel([In] uint nChannel); /// The SetLevel method sets the volume level, in decibels, of the specified channel. /// /// The number of the selected channel. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The new volume level in decibels. A positive value represents gain, and a negative value represents attenuation. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevel call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// /// If the caller specifies a value for fLevelDB that is an exact stepping value, the SetLevel method completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method will return either the value that was set, or one /// of the following values: /// /// /// /// If the set value was below the minimum, the GetLevel method returns the minimum value. /// /// /// If the set value was above the maximum, the GetLevel method returns the maximum value. /// /// /// /// If the set value was between two stepping values, the GetLevel method returns a value that could be the next stepping /// value above or the stepping value below the set value; the relative distances from the set value to the neighboring stepping /// values is unimportant. The value that the GetLevel method returns is whichever value has more of an impact on the /// signal path. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevel HRESULT // SetLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); new void SetLevel([In] uint nChannel, [In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelUniform method sets all channels in the audio stream to the same uniform volume level, in decibels. /// /// The new uniform level in decibels. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelUniform call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// If the specified uniform level is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports for a /// particular channel, the SetLevelUniform call clamps the value for that channel to the supported range and completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setleveluniform // HRESULT SetLevelUniform( float fLevelDB, LPCGUID pguidEventContext ); new void SetLevelUniform([In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelAllChannels method sets the volume levels, in decibels, of all the channels in the audio stream. /// /// /// Pointer to an array of volume levels. This parameter points to a caller-allocated float array into which the method /// writes the new volume levels, in decibels, for all the channels. The method writes the level for a particular channel into /// the array element whose index matches the channel number. If the audio stream contains n channels, the channels are numbered /// 0 to n– 1. To get the number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The number of elements in the aLevelsDB array. If this parameter does not match the number of channels in the audio stream, /// the method fails without modifying the aLevelsDB array. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelAllChannels call changes the state of the level control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// If the specified level value for any channel is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports /// for that channel, the SetLevelAllChannels call clamps the value to the supported range and completes successfully. A /// subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevelallchannels // HRESULT SetLevelAllChannels( float [] aLevelsDB, ULONG cChannels, LPCGUID pguidEventContext ); new void SetLevelAllChannels([In, MarshalAs(UnmanagedType.LPArray)] float[] aLevelsDB, [In] uint cChannels, [Optional] in Guid pguidEventContext); } /// /// /// The IAudioMute interface provides access to a hardware mute control. The client obtains a reference to the /// IAudioMute interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioMute. The call to IPart::Activate succeeds only if the subunit supports the IAudioMute interface. Only a /// subunit object that represents a hardware mute control function will support this interface. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioMute interface provides convenient /// access to the KSPROPERTY_AUDIO_MUTE property of a subunit that has a subtype GUID value of KSNODETYPE_MUTE. To obtain the /// subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, see /// the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiomute [PInvokeData("devicetopology.h", MSDNShortId = "53d49af7-81c3-4e75-ba06-dcee34d84292")] [ComImport, Guid("DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioMute { /// The SetMute method enables or disables the mute control. /// /// The new muting state. If bMuted is TRUE (nonzero), the method enables muting. If FALSE, the method disables muting. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetMute call changes the state of the mute control, all clients that have registered IControlChangeNotify interfaces /// with that control receive notifications. In its implementation of the OnNotify method, a client can inspect the /// event-context GUID to discover whether it or another client is the source of the control-change event. If the caller /// supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiomute-setmute HRESULT SetMute( BOOL // bMuted, LPCGUID pguidEventContext ); void SetMute([In] [MarshalAs(UnmanagedType.Bool)] bool bMuted, [Optional] in Guid pguidEventContext); /// The GetMute method gets the current state (enabled or disabled) of the mute control. /// /// Pointer to a BOOL variable into which the method writes the current state of the mute control. If the state is /// TRUE, muting is enabled. If FALSE, it is disabled. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiomute-getmute HRESULT GetMute( BOOL // *pbMuted ); [return: MarshalAs(UnmanagedType.Bool)] bool GetMute(); } /// /// /// The IAudioOutputSelector interface provides access to a hardware demultiplexer control (output selector). The client /// obtains a reference to the IAudioOutputSelector interface of a subunit by calling the IPart::Activate method with /// parameter refiid set to REFIID IID_IAudioOutputSelector. The call to IPart::Activate succeeds only if the subunit /// supports the IAudioOutputSelector interface. Only a subunit object that represents a hardware output selector will /// support this interface. /// /// /// Each output of an output selector is identified by the local ID of the part (a connector or subunit of a device topology) with a /// direct link to the output. A local ID is a number that uniquely identifies a part among all the parts in a device topology. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioOutputSelector interface provides /// convenient access to the KSPROPERTY_AUDIO_DEMUX_DEST property of a subunit that has a subtype GUID value of KSNODETYPE_DEMUX. To /// obtain the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node /// types, see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiooutputselector [PInvokeData("devicetopology.h", MSDNShortId = "571a44b6-972f-4d75-a31f-0e02cf728764")] [ComImport, Guid("BB515F69-94A7-429e-8B9C-271B3F11A3AB"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioOutputSelector { /// /// The GetSelection method gets the local ID of the part that is connected to the selector output that is currently selected. /// /// /// Pointer to a UINT variable into which the method writes the local ID of the part that has a direct link to the /// currently selected selector output. /// /// /// A local ID is a number that uniquely identifies a part among all parts in a device topology. To obtain a pointer to the /// IPart interface of a part from its local ID, call the IDeviceTopology::GetPartById method. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiooutputselector-getselection HRESULT // GetSelection( UINT *pnIdSelected ); uint GetSelection(); /// The SetSelection method selects one of the outputs of the output selector. /// /// The new selector output. The caller should set this parameter to the local ID of a part that has a direct link to one of the /// selector outputs. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetSelection call changes the state of the output-selector control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// A local ID is a number that uniquely identifies a part among all parts in a device topology. To obtain the local ID of a /// part, call the IPart::GetLocalId method on the part object. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiooutputselector-setselection HRESULT // SetSelection( UINT nIdSelect, LPCGUID pguidEventContext ); void SetSelection([In] uint nIdSelect, [Optional] in Guid pguidEventContext); } /// /// /// The IAudioPeakMeter interface provides access to a hardware peak-meter control. The client obtains a reference to the /// IAudioPeakMeter interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioPeakMeter. The call to IPart::Activate succeeds only if the subunit supports the IAudioPeakMeter /// interface. Only a subunit object that represents a hardware peak meter will support this interface. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioPeakMeter interface provides convenient /// access to the KSPROPERTY_AUDIO_PEAKMETER property of a subunit that has a subtype GUID value of KSNODETYPE_PEAKMETER. To obtain /// the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, /// see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiopeakmeter [PInvokeData("devicetopology.h", MSDNShortId = "524d83ff-4303-448c-a070-58d17dec03ba")] [ComImport, Guid("DD79923C-0599-45e0-B8B6-C8DF7DB6E796"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioPeakMeter { /// The GetChannelCount method gets the number of channels in the audio stream. /// A UINT variable into which the method writes the channel count. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiopeakmeter-getchannelcount HRESULT // GetChannelCount( UINT *pcChannels ); uint GetChannelCount(); /// /// The GetLevel method gets the peak level that the peak meter recorded for the specified channel since the peak level /// for that channel was previously read. /// /// /// The channel number. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the number of /// channels in the stream, call the IAudioPeakMeter::GetChannelCount method. /// /// A float variable into which the method writes the peak meter level in decibels. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iaudiopeakmeter-getlevel HRESULT // GetLevel( UINT nChannel, float *pfLevel ); float GetLevel([In] uint nChannel); } /// /// /// The IAudioTreble interface provides access to a hardware treble-level control. The client obtains a reference to the /// IAudioTreble interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioTreble. The call to IPart::Activate succeeds only if the subunit supports the IAudioTreble interface. /// Only a subunit object that represents a hardware function for controlling the level of the treble frequencies in each channel /// will support this interface. /// /// /// The IAudioTreble interface provides per-channel controls for setting and getting the gain or attenuation level of the /// treble frequencies in the audio stream. If a treble-level hardware control can only attenuate the channels in the audio stream, /// then the maximum treble level for any channel is 0 dB. If a treble-level control can provide gain (amplification), then the /// maximum treble level is greater than 0 dB. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioTreble interface provides convenient /// access to the KSPROPERTY_AUDIO_TREBLE property of a subunit that has a subtype GUID value of KSNODETYPE_TONE. To obtain the /// subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node types, see /// the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiotreble [PInvokeData("devicetopology.h", MSDNShortId = "3ace174e-c21c-41e7-9830-80d247d8437f")] [ComImport, Guid("0A717812-694E-4907-B74B-BAFA5CFDCA7B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioTreble : IPerChannelDbLevel { /// The GetChannelCount method gets the number of channels in the audio stream. /// A UINT variable into which the method writes the channel count (the number of channels in the audio stream). // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getchannelcount // HRESULT GetChannelCount( UINT *pcChannels ); new uint GetChannelCount(); /// The GetLevelRange method gets the range, in decibels, of the volume level of the specified channel. /// /// The number of the selected channel. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// Pointer to a float variable into which the method writes the minimum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the maximum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the stepping value between consecutive volume levels in the /// range *pfMinLevelDB to *pfMaxLevelDB. If the difference between the maximum and minimum volume levels is d decibels, and the /// range is divided into n steps (uniformly sized intervals), then the volume can have n + 1 discrete levels and the size of /// the step between consecutive levels is d / n decibels. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevelrange HRESULT // GetLevelRange( UINT nChannel, float *pfMinLevelDB, float *pfMaxLevelDB, float *pfStepping ); new void GetLevelRange([In] uint nChannel, out float pfMinLevelDB, out float pfMaxLevelDB, out float pfStepping); /// The GetLevel method gets the volume level, in decibels, of the specified channel. /// /// The channel number. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the number of /// channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// A float variable into which the method writes the volume level, in decibels, of the specified channel. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevel HRESULT // GetLevel( UINT nChannel, float *pfLevelDB ); new float GetLevel([In] uint nChannel); /// The SetLevel method sets the volume level, in decibels, of the specified channel. /// /// The number of the selected channel. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The new volume level in decibels. A positive value represents gain, and a negative value represents attenuation. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevel call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// /// If the caller specifies a value for fLevelDB that is an exact stepping value, the SetLevel method completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method will return either the value that was set, or one /// of the following values: /// /// /// /// If the set value was below the minimum, the GetLevel method returns the minimum value. /// /// /// If the set value was above the maximum, the GetLevel method returns the maximum value. /// /// /// /// If the set value was between two stepping values, the GetLevel method returns a value that could be the next stepping /// value above or the stepping value below the set value; the relative distances from the set value to the neighboring stepping /// values is unimportant. The value that the GetLevel method returns is whichever value has more of an impact on the /// signal path. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevel HRESULT // SetLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); new void SetLevel([In] uint nChannel, [In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelUniform method sets all channels in the audio stream to the same uniform volume level, in decibels. /// /// The new uniform level in decibels. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelUniform call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// If the specified uniform level is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports for a /// particular channel, the SetLevelUniform call clamps the value for that channel to the supported range and completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setleveluniform // HRESULT SetLevelUniform( float fLevelDB, LPCGUID pguidEventContext ); new void SetLevelUniform([In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelAllChannels method sets the volume levels, in decibels, of all the channels in the audio stream. /// /// /// Pointer to an array of volume levels. This parameter points to a caller-allocated float array into which the method /// writes the new volume levels, in decibels, for all the channels. The method writes the level for a particular channel into /// the array element whose index matches the channel number. If the audio stream contains n channels, the channels are numbered /// 0 to n– 1. To get the number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The number of elements in the aLevelsDB array. If this parameter does not match the number of channels in the audio stream, /// the method fails without modifying the aLevelsDB array. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelAllChannels call changes the state of the level control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// If the specified level value for any channel is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports /// for that channel, the SetLevelAllChannels call clamps the value to the supported range and completes successfully. A /// subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevelallchannels // HRESULT SetLevelAllChannels( float [] aLevelsDB, ULONG cChannels, LPCGUID pguidEventContext ); new void SetLevelAllChannels([In, MarshalAs(UnmanagedType.LPArray)] float[] aLevelsDB, [In] uint cChannels, [Optional] in Guid pguidEventContext); } /// /// /// The IAudioVolumeLevel interface provides access to a hardware volume control. The client obtains a reference to the /// IAudioVolumeLevel interface of a subunit by calling the IPart::Activate method with parameter refiid set to REFIID /// IID_IAudioVolumeLevel. The call to IPart::Activate succeeds only if the subunit supports the IAudioVolumeLevel /// interface. Only a subunit object that represents a hardware volume-level control will support this interface. /// /// /// The IAudioVolumeLevel interface provides per-channel controls for setting and getting the gain or attenuation levels in /// an the audio stream. If a volume-level hardware control can only attenuate the channels in the audio stream, then the maximum /// volume level for any channel is 0 dB. If a volume-level control can provide gain (amplification), then the maximum volume level /// is greater than 0 dB. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IAudioVolumeLevel interface provides /// convenient access to the KSPROPERTY_AUDIO_VOLUMELEVEL property of a subunit that has a subtype GUID value of KSNODETYPE_VOLUME. /// To obtain the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about KS properties and KS node /// types, see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iaudiovolumelevel [PInvokeData("devicetopology.h", MSDNShortId = "5e7d7111-e4b0-43b3-af35-9878d1a19e5f")] [ComImport, Guid("7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioVolumeLevel : IPerChannelDbLevel { /// The GetChannelCount method gets the number of channels in the audio stream. /// A UINT variable into which the method writes the channel count (the number of channels in the audio stream). // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getchannelcount // HRESULT GetChannelCount( UINT *pcChannels ); new uint GetChannelCount(); /// The GetLevelRange method gets the range, in decibels, of the volume level of the specified channel. /// /// The number of the selected channel. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// Pointer to a float variable into which the method writes the minimum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the maximum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the stepping value between consecutive volume levels in the /// range *pfMinLevelDB to *pfMaxLevelDB. If the difference between the maximum and minimum volume levels is d decibels, and the /// range is divided into n steps (uniformly sized intervals), then the volume can have n + 1 discrete levels and the size of /// the step between consecutive levels is d / n decibels. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevelrange HRESULT // GetLevelRange( UINT nChannel, float *pfMinLevelDB, float *pfMaxLevelDB, float *pfStepping ); new void GetLevelRange([In] uint nChannel, out float pfMinLevelDB, out float pfMaxLevelDB, out float pfStepping); /// The GetLevel method gets the volume level, in decibels, of the specified channel. /// /// The channel number. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the number of /// channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// A float variable into which the method writes the volume level, in decibels, of the specified channel. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevel HRESULT // GetLevel( UINT nChannel, float *pfLevelDB ); new float GetLevel([In] uint nChannel); /// The SetLevel method sets the volume level, in decibels, of the specified channel. /// /// The number of the selected channel. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The new volume level in decibels. A positive value represents gain, and a negative value represents attenuation. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevel call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// /// If the caller specifies a value for fLevelDB that is an exact stepping value, the SetLevel method completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method will return either the value that was set, or one /// of the following values: /// /// /// /// If the set value was below the minimum, the GetLevel method returns the minimum value. /// /// /// If the set value was above the maximum, the GetLevel method returns the maximum value. /// /// /// /// If the set value was between two stepping values, the GetLevel method returns a value that could be the next stepping /// value above or the stepping value below the set value; the relative distances from the set value to the neighboring stepping /// values is unimportant. The value that the GetLevel method returns is whichever value has more of an impact on the /// signal path. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevel HRESULT // SetLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); new void SetLevel([In] uint nChannel, [In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelUniform method sets all channels in the audio stream to the same uniform volume level, in decibels. /// /// The new uniform level in decibels. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelUniform call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// If the specified uniform level is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports for a /// particular channel, the SetLevelUniform call clamps the value for that channel to the supported range and completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setleveluniform // HRESULT SetLevelUniform( float fLevelDB, LPCGUID pguidEventContext ); new void SetLevelUniform([In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelAllChannels method sets the volume levels, in decibels, of all the channels in the audio stream. /// /// /// Pointer to an array of volume levels. This parameter points to a caller-allocated float array into which the method /// writes the new volume levels, in decibels, for all the channels. The method writes the level for a particular channel into /// the array element whose index matches the channel number. If the audio stream contains n channels, the channels are numbered /// 0 to n– 1. To get the number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The number of elements in the aLevelsDB array. If this parameter does not match the number of channels in the audio stream, /// the method fails without modifying the aLevelsDB array. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelAllChannels call changes the state of the level control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// If the specified level value for any channel is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports /// for that channel, the SetLevelAllChannels call clamps the value to the supported range and completes successfully. A /// subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevelallchannels // HRESULT SetLevelAllChannels( float [] aLevelsDB, ULONG cChannels, LPCGUID pguidEventContext ); new void SetLevelAllChannels([In, MarshalAs(UnmanagedType.LPArray)] float[] aLevelsDB, [In] uint cChannels, [Optional] in Guid pguidEventContext); } /// /// /// The IConnector interface represents a point of connection between components. The client obtains a reference to an /// IConnector interface by calling the IDeviceTopology::GetConnector or IConnector::GetConnectedTo method, or by calling the /// IPart::QueryInterface method with parameter iid set to REFIID IID_IConnector. /// /// An IConnector interface instance can represent: /// /// /// An audio jack on a piece of hardware /// /// /// An internal connection to an integrated endpoint device (for example, a built-in microphone in a laptop computer) /// /// /// A software connection implemented through DMA transfers /// /// /// /// The methods in the IConnector interface can describe various kinds of connectors. A connector has a type (a ConnectorType /// enumeration constant) and a subtype (a GUID obtained from the IPart::GetSubType method). /// /// /// A part in a device topology can be either a connector or a subunit. The IPart interface provides methods that are common to /// connectors and subunits. /// /// /// For code examples that use the IConnector interface, see the implementations of the GetHardwareDeviceTopology and /// SelectCaptureDevice functions in Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iconnector [PInvokeData("devicetopology.h", MSDNShortId = "6eb5b439-3ac7-4c0b-84e2-b246c1b946a5")] [ComImport, Guid("9c2c4058-23f5-41de-877a-df3af236a09e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IConnector { /// The GetType method gets the type of this connector. /// /// The connector type. The connector type is one of the following ConnectorType enumeration constants: /// Unknown_Connector /// Physical_Internal /// Physical_External /// Software_IO /// Software_Fixed /// Network /// /// /// /// A connector corresponds to a "pin" in kernel streaming (KS) terminology. The mapping of KS pins to connectors is as follows: /// /// /// /// /// If the KS pin communication type is KSPIN_COMMUNICATION_SINK, KSPIN_COMMUNICATION_SOURCE, or KSPIN_COMMUNICATION_BOTH, then /// the connector type is Software_IO. /// /// /// /// /// Else, if the pin is part of a physical connection between two KS filters (devices) in the same audio adapter or in different /// audio adapters, then the connector type is Software_Fixed. /// /// /// /// /// Else, if the KS pin category is KSNODETYPE_SPEAKER, KSNODETYPE_MICROPHONE, KSNODETYPE_LINE_CONNECTOR, or /// KSNODETYPE_SPDIF_INTERFACE, the connector type is Physical_External. /// /// /// /// Else, for a pin that does not meet any of the preceding criteria, the connector type is Physical_Internal. /// /// /// For more information about KS pins, see the Windows DDK documentation. /// /// For a code example that calls the GetType method, see the implementation of the SelectCaptureDevice function in /// Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-gettype HRESULT GetType( // ConnectorType *pType ); ConnectorType GetType(); /// The GetDataFlow method gets the direction of data flow through this connector. /// /// The data-flow direction. The direction is one of the following DataFlow enumeration values: /// In /// Out /// /// If data flows into the device through the connector, the data-flow direction is In. Otherwise, the data-flow direction is Out. /// /// /// /// For a code example that calls this method, see the implementation of the SelectCaptureDevice function in Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-getdataflow HRESULT // GetDataFlow( DataFlow *pFlow ); DataFlow GetDataFlow(); /// The ConnectTo method connects this connector to a connector in another device-topology object. /// /// The other connector. This parameter points to the IConnector interface of the connector object that represents the connector /// in the other device topology. The caller is responsible for releasing its counted reference to the IConnector /// interface when it is no longer needed. The ConnectTo method obtains its own reference to this interface. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-connectto HRESULT ConnectTo( // IConnector *pConnectTo ); void ConnectTo([In] IConnector pConnectTo); /// The Disconnect method disconnects this connector from another connector. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-disconnect HRESULT Disconnect(); void Disconnect(); /// The IsConnected method indicates whether this connector is connected to another connector. /// /// A BOOL variable into which the method writes the connection state. If the state is TRUE, this connector is /// connected to another connector. If FALSE, this connector is unconnected. /// /// /// For a code example that calls the IsConnected method, see the implementation of the SelectCaptureDevice function in /// Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-isconnected HRESULT // IsConnected( BOOL *pbConnected ); [return: MarshalAs(UnmanagedType.Bool)] bool IsConnected(); /// The GetConnectedTo method gets the connector to which this connector is connected. /// /// The IConnector interface of the other connector object. Through this method, the caller obtains a counted reference to the /// interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's /// Release method. If the GetConnectedTo call fails, *ppConTo is NULL. /// /// /// /// For code examples that call this method, see the implementations of the GetHardwareDeviceTopology and SelectCaptureDevice /// functions in Device Topologies. /// /// /// For information about Software_IO connections, see ConnectorType Enumeration. For information about the HRESULT_FROM_WIN32 /// macro, see the Windows SDK documentation. For information about the DEVICE_STATE_NOTPRESENT device state, see /// DEVICE_STATE_XXX Constants. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-getconnectedto HRESULT // GetConnectedTo( IConnector **ppConTo ); IConnector GetConnectedTo(); /// /// The GetConnectorIdConnectedTo method gets the global ID of the connector, if any, that this connector is connected to. /// /// /// A string pointer into which the method writes the address of a null-terminated, wide-character string that contains the /// other connector's global ID. The method allocates the storage for the string. If the GetConnectorIdConnectedTo call /// fails, *ppwstrConnectorId is NULL. For information about CoTaskMemFree, see the Windows SDK documentation. /// /// /// A global ID is a string that uniquely identifies a part among all parts in all device topologies in the system. Clients /// should treat this string as opaque. That is, clients should not attempt to parse the contents of the string to obtain /// information about the part. The reason is that the string format is undefined and might change from one implementation of /// the DeviceTopology API to the next. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-getconnectoridconnectedto // HRESULT GetConnectorIdConnectedTo( LPWSTR *ppwstrConnectorId ); SafeCoTaskMemString GetConnectorIdConnectedTo(); /// /// The GetDeviceIdConnectedTo method gets the device identifier of the audio device, if any, that this connector is /// connected to. /// /// /// A string pointer into which the method writes the address of a null-terminated, wide-character string that contains the /// device identifier of the connected device. The method allocates the storage for the string. If the /// GetDeviceIdConnectedTo call fails, *ppwstrDeviceId is NULL. For information about CoTaskMemFree, see /// the Windows SDK documentation. /// /// /// /// The device identifier obtained from this method can be used as an input parameter to the IMMDeviceEnumerator::GetDevice method. /// /// This method is functionally equivalent to, but more efficient than, the following series of method calls: /// /// /// Call the IConnector::GetConnectedTo method to obtain the IConnector interface of the "to" connector. /// /// /// /// Call the IConnector::QueryInterface method (with parameter iid set to REFIID IID_IPart) to obtain the IPart /// interface of the "to" connector. /// /// /// /// /// Call the IPart::GetTopologyObject method to obtain the IDeviceTopology interface of the "to" device (the device that /// contains the "to" connector). /// /// /// /// Call the IDeviceTopology::GetDeviceId method to obtain the device ID of the "to" device. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iconnector-getdeviceidconnectedto HRESULT // GetDeviceIdConnectedTo( LPWSTR *ppwstrDeviceId ); SafeCoTaskMemString GetDeviceIdConnectedTo(); } /// /// /// The IControlChangeNotify interface provides notifications when the status of a part (connector or subunit) changes. /// Unlike the other interfaces in this section, which are implemented by the DeviceTopology API, the IControlChangeNotify /// interface must be implemented by a client. To receive notifications, the client passes a pointer to its /// IControlChangeNotify interface instance as a parameter to the IPart::RegisterControlChangeCallback method. /// /// /// After registering its IControlChangeNotify interface, the client receives event notifications in the form of callbacks /// through the OnNotify method in the interface. /// /// /// In implementing the IControlChangeNotify interface, the client should observe these rules to avoid deadlocks and /// undefined behavior: /// /// /// /// /// The methods in the interface must be nonblocking. The client should never wait on a synchronization object during an event callback. /// /// /// /// The client should never call the IPart::UnregisterControlChangeCallback method during an event callback. /// /// /// The client should never release the final reference on an MMDevice API object during an event callback. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-icontrolchangenotify [PInvokeData("devicetopology.h", MSDNShortId = "e50e13c2-1ef3-46f6-8c53-f99cc1631a79")] [ComImport, Guid("A09513ED-C709-4d21-BD7B-5F34C47F3947"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IControlChangeNotify { /// The OnNotify method notifies the client when the status of a connector or subunit changes. /// /// The process ID of the client that changed the state of the control. If a notification is generated by a hardware event, this /// process ID will differ from the client's process ID. For more information, see Remarks. /// /// /// A pointer to the context GUID for the control-change event. The client that initiates the control change supplies this GUID. /// For more information, see Remarks. /// /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. /// /// A client can use this method to keep track of control changes made by other processes and by the hardware. However, a client /// that changes a control setting can typically disregard the notification that the control change generates. In its /// implementation of the OnNotify method, a client can inspect the dwSenderProcessId and pguidEventContext parameters to /// discover whether it or another client is the source of the control-change event. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-icontrolchangenotify-onnotify HRESULT // OnNotify( DWORD dwSenderProcessId, LPCGUID pguidEventContext ); [PreserveSig] HRESULT OnNotify([In] uint dwSenderProcessId, [Optional] in Guid pguidEventContext); } /// /// The IControlInterface interface represents a control interface on a part (connector or subunit) in a device topology. The /// client obtains a reference to a part's IControlInterface interface by calling the IPart::GetControlInterface method. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-icontrolinterface [PInvokeData("devicetopology.h", MSDNShortId = "fdd91f65-e45c-4f14-a55c-a44be1661950")] [ComImport, Guid("45d37c3f-5140-444a-ae24-400789f3cbf3"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IControlInterface { /// The GetName method gets the friendly name for the audio function that the control interface encapsulates. /// /// A string pointer into which the method writes the address of a null-terminated, wide-character string that contains the /// friendly name. The method allocates the storage for the string. The caller is responsible for freeing the storage, when it /// is no longer needed, by calling the CoTaskMemFree function. If the GetName call fails, *ppwstrName is /// NULL. For information about CoTaskMemFree, see the Windows SDK documentation. /// /// /// As an example of a friendly name, a subunit with an IAudioPeakMeter interface might have the friendly name "peak meter". /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-icontrolinterface-getname HRESULT // GetName( LPWSTR *ppwstrName ); SafeCoTaskMemString GetName(); /// The GetIID method gets the interface ID of the function-specific control interface of the part. /// /// A GUID variable into which the method writes the interface ID of the function-specific control interface of the part. For /// more information, see Remarks. /// /// /// /// An object that represents a part (connector or subunit) has two control interfaces. The first is a generic control /// interface, IControlInterface, which has methods that are common to all types of controls. The second is a function-specific /// control interface that has methods that apply to a particular type of control. The GetIID method gets the interface /// ID of the second control interface. The client can supply this interface ID to the IPart::Activate method to create an /// instance of the part's function-specific interface. /// /// The method gets one of the function-specific interface IDs shown in the following table. /// /// /// Interface ID /// Interface name /// /// /// IID_IAudioAutoGainControl /// IAudioAutoGainControl /// /// /// IID_IAudioBass /// IAudioBass /// /// /// IID_IAudioChannelConfig /// IAudioChannelConfig /// /// /// IID_IAudioInputSelector /// IAudioInputSelector /// /// /// IID_IAudioLoudness /// IAudioLoudness /// /// /// IID_IAudioMidrange /// IAudioMidrange /// /// /// IID_IAudioMute /// IAudioMute /// /// /// IID_IAudioOutputSelector /// IAudioOutputSelector /// /// /// IID_IAudioPeakMeter /// IAudioPeakMeter /// /// /// IID_IAudioTreble /// IAudioTreble /// /// /// IID_IAudioVolumeLevel /// IAudioVolumeLevel /// /// /// IID_IDeviceSpecificProperty /// IDeviceSpecificProperty /// /// /// IID_IKsFormatSupport /// IKsFormatSupport /// /// /// IID_IKsJackDescription /// IKsJackDescription /// /// /// /// To obtain the interface ID of an interface, use the __uuidof operator. For example, the interface ID of the /// IAudioAutoGainControl interface is defined as follows: /// /// For more information about the __uuidof operator, see the Windows SDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-icontrolinterface-getiid HRESULT GetIID( // GUID *pIID ); Guid GetIID(); } /// /// /// The IDeviceSpecificProperty interface provides access to the control value of a device-specific hardware control. A /// client obtains a reference to an IDeviceSpecificProperty interface of a part by calling the IPart::Activate method with /// parameter refiid set to REFIID IID_IDeviceSpecificProperty. The call to IPart::Activate succeeds only if the part /// supports the IDeviceSpecificProperty interface. A part supports this interface only if the underlying hardware control /// has a device-specific control value and the control cannot be adequately represented by any other interface in the /// DeviceTopology API. /// /// /// Typically, a device-specific property is useful only to a client that can infer the meaning of the property value from /// information such as the part type, part subtype, and part name. The client can obtain this information by calling the /// IPart::GetPartType, IPart::GetSubType, and IPart::GetName methods. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware control parameters in subunits (referred to as KS nodes). The IDeviceSpecificProperty interface provides /// convenient access to the KSPROPERTY_AUDIO_DEV_SPECIFIC property of a subunit that has a subtype GUID value of /// KSNODETYPE_DEV_SPECIFIC. To obtain the subtype GUID of a subunit, call the IPart::GetSubType method. For more information about /// KS properties and KS node types, see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-idevicespecificproperty [PInvokeData("devicetopology.h", MSDNShortId = "52873fe2-7f59-4a30-b526-cbefa27a81bb")] [ComImport, Guid("3B22BCBF-2586-4af0-8583-205D391B807C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IDeviceSpecificProperty { /// The GetType method gets the data type of the device-specific property value. /// /// A VARTYPE variable into which the method writes a VARTYPE enumeration value that indicates the data type of /// the device-specific property value. For more information about VARTYPE and VARTYPE, see the Windows SDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicespecificproperty-gettype HRESULT // GetType( VARTYPE *pVType ); VARTYPE GetType(); /// The GetValue method gets the current value of the device-specific property. /// Pointer to a caller-allocated buffer into which the method writes the property value. /// /// [inout] Pointer to a DWORD variable that specifies the size in bytes of the property value. On entry, *pcbValue /// contains the size of the caller-allocated buffer (or 0 if pvValue is NULL). Before returning, the method writes the /// actual size of the property value written to the buffer (or the required size if the buffer is too small or if pvValue is NULL). /// /// /// /// If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values /// shown in the following table. /// /// /// /// Return code /// Description /// /// /// E_POINTER /// Pointer pcbValue is NULL. /// /// /// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) /// /// The buffer pointed to by parameter pvValue is too small to contain the property value, or pvValue is NULL and the size of /// the property value is fixed rather than variable. For information about this macro, see the Windows SDK documentation. /// /// /// /// /// /// /// If the size of the property value is variable rather than fixed, the caller can obtain the required buffer size by calling /// GetValue with parameter pvValue = NULL and *pcbValue = 0. The method writes the required buffer size to /// *pcbValue. With this information, the caller can allocate a buffer of the required size and call GetValue a second /// time to obtain the property value. /// /// /// If the caller-allocated buffer is too small to hold the property value, GetValue writes the required buffer size to /// *pcbValue and returns an error status code. In this case, it writes nothing to the buffer pointed by pvValue. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicespecificproperty-getvalue HRESULT // GetValue( void *pvValue, DWORD *pcbValue ); [PreserveSig] HRESULT GetValue([Out] IntPtr pvValue, ref uint pcbValue); /// The SetValue method sets the value of the device-specific property. /// Pointer to the new value for the device-specific property. /// The size in bytes of the device-specific property value. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetValue call changes the state of the control, all clients that have registered IControlChangeNotify interfaces with /// that control receive notifications. In its implementation of the OnNotify method, a client can inspect the /// event-context GUID to discover whether it or another client is the source of the control-change event. If the caller /// supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicespecificproperty-setvalue HRESULT // SetValue( void *pvValue, DWORD cbValue, LPCGUID pguidEventContext ); void SetValue([In] IntPtr pvValue, uint cbValue, [Optional] in Guid pguidEventContext); /// The Get4BRange method gets the 4-byte range of the device-specific property value. /// Pointer to a LONG variable into which the method writes the minimum property value. /// Pointer to a LONG variable into which the method writes the maximum property value. /// /// Pointer to a LONG variable into which the method writes the stepping value between consecutive property values in the /// range *plMin to *plMax. If the difference between the maximum and minimum property values is d, and the range is divided /// into n steps (uniformly sized intervals), then the property can take n + 1 discrete values and the size of the step between /// consecutive values is d / n. /// /// /// This method reports the range and step size for a property value that is a 32-bit signed or unsigned integer. These two data /// types are represented by VARENUM enumeration constants VT_I4 and VT_UI4, respectively. If the property value is not a /// 32-bit integer, then the method returns an error status code. For more information about VARENUM, see the Windows SDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicespecificproperty-get4brange // HRESULT Get4BRange( LONG *plMin, LONG *plMax, LONG *plStepping ); void Get4BRange(out int plMin, out int plMax, out int plStepping); } /// /// /// The IDeviceTopology interface provides access to the topology of an audio device. The topology of an audio adapter device /// consists of the data paths that lead to and from audio endpoint devices and the control points that lie along the paths. An /// audio endpoint device also has a topology, but it is trivial, as explained in Device Topologies. A client obtains a reference to /// the IDeviceTopology interface for an audio endpoint device by following these steps: /// /// /// /// /// By using one of the techniques described in IMMDevice Interface, obtain a reference to the IMMDevice interface for an /// audio endpoint device. /// /// /// /// Call the IMMDevice::Activate method with parameter refiid set to REFIID IID_IDeviceTopology. /// /// /// /// After obtaining the IDeviceTopology interface for an audio endpoint device, an application can explore the topologies of /// the audio adapter devices to which the endpoint device is connected. /// /// /// For code examples that use the IDeviceTopology interface, see the implementations of the GetHardwareDeviceTopology and /// SelectCaptureDevice functions in Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-idevicetopology [PInvokeData("devicetopology.h", MSDNShortId = "1b509f69-6277-40c0-a293-02afc30d464a")] [ComImport, Guid("2A07407E-6497-4A18-9787-32F79BD0D98F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IDeviceTopology { /// The GetConnectorCount method gets the number of connectors in the device-topology object. /// /// A UINT pointer variable into which the method writes the connector count (the number of connectors in the device topology). /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getconnectorcount HRESULT // GetConnectorCount( UINT *pCount ); uint GetConnectorCount(); /// The GetConnector method gets the connector that is specified by a connector number. /// /// The connector number. If a device topology contains n connectors, the connectors are numbered 0 to n – 1. To get the number /// of connectors in the device topology, call the IDeviceTopology::GetConnectorCount method. /// /// /// The IConnector interface of the connector object. Through this method, the caller obtains a counted reference to the /// interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's /// Release method. If the GetConnector call fails, *ppConnector is NULL. /// /// /// For code examples that call the GetConnector method, see the implementations of the GetHardwareDeviceTopology and /// SelectCaptureDevice functions in Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getconnector HRESULT // GetConnector( UINT nIndex, IConnector **ppConnector ); IConnector GetConnector([In] uint nIndex); /// The GetSubunitCount method gets the number of subunits in the device topology. /// /// A UINT variable into which the method writes the subunit count (the number of subunits in the device topology). /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getsubunitcount HRESULT // GetSubunitCount( UINT *pCount ); uint GetSubunitCount(); /// The GetSubunit method gets the subunit that is specified by a subunit number. /// /// The subunit number. If a device topology contains n subunits, the subunits are numbered from 0 to n– 1. To get the number of /// subunits in the device topology, call the IDeviceTopology::GetSubunitCount method. /// /// /// The ISubunit interface of the subunit object. Through this method, the caller obtains a counted reference to the interface. /// The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's /// Release method. If the GetSubunit call fails, *ppSubunit is NULL. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getsubunit HRESULT // GetSubunit( UINT nIndex, ISubunit **ppSubunit ); ISubunit GetSubunit([In] uint nIndex); /// The GetPartById method gets a part that is identified by its local ID. /// The part to get. This parameter is the local ID of the part. For more information, see Remarks. /// /// The IPart interface of the part object that is identified by nId. Through this method, the caller obtains a counted /// reference to the interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling /// the interface's Release method. If the GetPartById call fails, *ppPart is NULL. /// /// /// A local ID is a number that uniquely identifies a part among all the parts in a device topology. The /// IAudioInputSelector::GetSelection and IAudioOutputSelector::GetSelection methods retrieve the local ID of a connected part. /// The IAudioInputSelector::SetSelection and IAudioOutputSelector::SetSelection methods select the input or output that is /// connected to a part that is identified by its local ID. When you have a pointer to a part object, you can call the /// IPart::GetLocalId method to get the local ID of the part. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getpartbyid HRESULT // GetPartById( UINT nId, IPart **ppPart ); IPart GetPartById([In] uint nId); /// /// The GetDeviceId method gets the device identifier of the device that is represented by the device-topology object. /// /// /// A pointer variable into which the method writes the address of a null-terminated, wide-character string that contains the /// device identifier. The method allocates the storage for the string. The caller is responsible for freeing the storage, when /// it is no longer needed, by calling the CoTaskMemFree function. If the GetDeviceId call fails, *ppwstrDeviceId /// is NULL. For information about CoTaskMemFree, see the Windows SDK documentation. /// /// /// /// The device identifier obtained from this method can be used as an input parameter to the IMMDeviceEnumerator::GetDevice method. /// /// For a code example that uses the GetDeviceId method, see Using the IKsControl Interface to Access Audio Properties. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getdeviceid HRESULT // GetDeviceId( LPWSTR *ppwstrDeviceId ); SafeCoTaskMemString GetDeviceId(); /// The GetSignalPath method gets a list of parts in the signal path that links two parts, if the path exists. /// /// Pointer to the "from" part. This parameter is a pointer to the IPart interface of the part at the beginning of the signal path. /// /// /// Pointer to the "to" part. This parameter is a pointer to the IPart interface of the part at the end of the signal path. /// /// /// Specifies whether to reject paths that contain mixed data. If bRejectMixedPaths is TRUE (nonzero), the method ignores /// any data path that contains a mixer (that is, a processing node that sums together two or more input signals). If /// FALSE, the method will try to find a path that connects the "from" and "to" parts regardless of whether the path /// contains a mixer. /// /// /// An IPartsList interface instance. This interface encapsulates the list of parts in the signal path that connects the "from" /// part to the "to" part. Through this method, the caller obtains a counted reference to the interface. The caller is /// responsible for releasing the interface, when it is no longer needed, by calling the interface's Release method. If /// the GetSignalPath call fails, *ppParts is NULL. /// /// /// /// This method creates an IPartsList interface instance that contains a list of the parts that lie along the specified /// signal path. The parts in the parts list are ordered according to their relative positions in the signal path. The "to" part /// is the first item in the list and the "from" part is the last item in the list. /// /// /// If the list contains n parts, the "to" and "from" parts are identified by list indexes 0 and n– 1, respectively. To get the /// number of parts in a parts list, call the IPartsList::GetCount method. To retrieve a part by its index, call the /// IPartsList::GetPart method. /// /// /// The parts in the signal path must all be part of the same device topology. The path cannot span boundaries between device topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-idevicetopology-getsignalpath HRESULT // GetSignalPath( IPart *pIPartFrom, IPart *pIPartTo, BOOL bRejectMixedPaths, IPartsList **ppParts ); IPartsList GetSignalPath([In] IPart pIPartFrom, [In] IPart pIPartTo, [In] [MarshalAs(UnmanagedType.Bool)] bool bRejectMixedPaths); } /// /// /// The IKsFormatSupport interface provides information about the audio data formats that are supported by a /// software-configured I/O connection (typically a DMA channel) between an audio adapter device and system memory. The client /// obtains a reference to the IKsFormatSupport interface of a part by calling the IPart::Activate method with parameter /// refiid set to REFIID IID_IKsFormatSupport. The call to IPart::Activate succeeds only if the part supports the /// IKsFormatSupport interface. Only a part object that represents a connector with a Software_IO connection type will /// support this interface. For more information about Software_IO, see ConnectorType Enumeration. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware description parameters in connectors (referred to as KS pins). The IKsFormatSupport interface provides /// convenient access to the KSPROPERTY_PIN_DATAINTERSECTION and KSPROPERTY_PIN_PROPOSEDDATAFORMAT properties of a connector to a /// system bus (typically, PCI or PCI Express) or an external bus (for example, USB). Not all drivers support the /// KSPROPERTY_PIN_PROPOSEDDATAFORMAT property. If a driver does not support this property, IKsFormatSupport uses the /// information in the KS data ranges for the connector to determine whether the connector supports the proposed format. For more /// information about KS properties, KS pins, and KS data ranges, see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iksformatsupport [ComImport, Guid("3CB4A69D-BB6F-4D2B-95B7-452D2C155DB5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IKsFormatSupport { /// /// The IsFormatSupported method indicates whether the audio endpoint device supports the specified audio stream format. /// /// /// Pointer to an audio-stream format specifier. This parameter points to a caller-allocated buffer that contains a format /// specifier. The specifier begins with a KSDATAFORMAT structure that might be followed by additional format information. For /// more information about KSDATAFORMAT and format specifiers, see the Windows DDK documentation. /// /// The size in bytes of the buffer that contains the format specifier. /// /// A BOOL variable into which the method writes a value to indicate whether the format is supported. The method writes /// TRUE if the device supports the format and FALSE if the device does not support the format. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksformatsupport-isformatsupported // HRESULT IsFormatSupported( PKSDATAFORMAT pKsFormat, DWORD cbFormat, BOOL *pbSupported ); [return: MarshalAs(UnmanagedType.Bool)] bool IsFormatSupported([In] IntPtr pKsFormat, [In] uint cbFormat); /// The GetDevicePreferredFormat method gets the preferred audio stream format for the connection. /// /// A pointer variable into which the method writes the address of a buffer that contains the format specifier for the preferred /// format. The specifier begins with a KSDATAFORMAT structure that might be followed by additional format information. /// The method allocates the storage for the format specifier. If the method fails, *ppKsFormat is NULL. For more /// information about KSDATAFORMAT, format specifiers, and CoTaskMemFree, see the Windows DDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksformatsupport-getdevicepreferredformat // HRESULT GetDevicePreferredFormat( PKSDATAFORMAT *ppKsFormat ); SafeCoTaskMemHandle GetDevicePreferredFormat(); } /// /// /// The IKsJackDescription interface provides information about the jacks or internal connectors that provide a physical /// connection between a device on an audio adapter and an external or internal endpoint device (for example, a microphone or CD /// player). The client obtains a reference to the IKsJackDescription interface of a part by calling the IPart::Activate /// method with parameter refiid set to REFIID IID_IKsJackDescription. The call to IPart::Activate succeeds only if /// the part supports the IKsJackDescription interface. Only a part object that represents a connector with a /// Physical_External or Physical_Internal connection type will support this interface. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware description parameters in connectors (referred to as KS pins). The IKsJackDescription interface provides /// convenient access to the KSPROPERTY_JACK_DESCRIPTION property of a connector to an endpoint device. For more information about /// KS properties and KS pins, see the Windows DDK documentation. /// /// /// /// /// If an audio endpoint device supports the IKsJackDescription interface, the Windows multimedia control panel, Mmsys.cpl, /// displays the jack information. To view the jack information, follow these steps: /// /// /// /// To run Mmsys.cpl, open a Command Prompt window and enter the following command: /// /// /// /// After the Mmsys.cpl window opens, select a device from either the list of playback devices or the list of recording devices, and /// click Properties. /// /// /// /// /// When the properties window opens, click General. If the selected property page displays the jack information for the /// device, the device supports the IKsJackDescription interface. If the property page displays the text "No jack information /// is available", the device does not support the interface. /// /// /// /// The following code example shows how to obtain the IKsJackDescription interface for an audio endpoint device: /// /// In the preceding code example, the GetJackInfo function takes two parameters. Input parameter pDevice points to the IMMDevice /// interface of an endpoint device. Output parameter ppJackDesc points to a pointer value into which the function writes the /// address of the corresponding IKsJackDescription interface, if the interface exists. If the interface does not exist, the /// function writes NULL to *ppJackDesc and returns error code E_NOINTERFACE. /// /// /// In the preceding code example, the call to IMMDevice::Activate retrieves the IDeviceTopology interface of the endpoint device. /// The device topology of an endpoint device contains a single connector (connector number 0) that connects to the adapter device. /// At the other side of this connection, the connector on the adapter device represents the audio jack or jacks that the endpoint /// device plugs into. The call to the IDeviceTopology::GetConnector method retrieves the IConnector interface of the connector on /// the endpoint device, and the IConnector::GetConnectedTo method call retrieves the corresponding connector on the adapter device. /// Finally, the IConnector::QueryInterface method call retrieves the IPart interface of the adapter device's connector, and /// the IPart::Activate method call retrieves the connector's IKsJackDescription interface, if it exists. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iksjackdescription [PInvokeData("devicetopology.h", MSDNShortId = "0ca9e719-7179-4302-99ff-df137141f58f")] [ComImport, Guid("4509F757-2D46-4637-8E62-CE7DB944F57B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IKsJackDescription { /// The GetJackCount method gets the number of jacks required to connect to an audio endpoint device. /// A UINT variable into which the method writes the number of jacks associated with the connector. /// /// /// An audio endpoint device that plays or records a stream that contains multiple channels might require a connection with more /// than one jack (physical connector). /// /// /// For example, a set of surround speakers that plays a 6-channel audio stream might require three stereo jacks. In this /// example, the first jack transmits the channels for the front-left and front-right speakers, the second jack transmits the /// channels for the front-center and low-frequency-effects (subwoofer) speakers, and the third jack transmits the channels for /// the side-left and side-right speakers. /// /// /// After calling this method to retrieve the jack count, call the IKsJackDescription::GetJackDescription method once for each /// jack to obtain a description of the jack. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksjackdescription-getjackcount HRESULT // GetJackCount( UINT *pcJacks ); uint GetJackCount(); /// The GetJackDescription method gets a description of an audio jack. /// /// The jack index. If the connection consists of n jacks, the jacks are numbered from 0 to n– 1. To get the number of jacks, /// call the IKsJackDescription::GetJackCount method. /// /// /// A structure of type KSJACK_DESCRIPTION that contains information about the jack. The buffer size must be at least sizeof(KSJACK_DESCRIPTION). /// /// /// /// When a user needs to plug an audio endpoint device into a jack or unplug it from a jack, an audio application can use the /// descriptive information that it retrieves from this method to help the user to find the jack. This information includes: /// /// /// /// The physical location of the jack on the computer chassis or external box. /// /// /// The color of the jack. /// /// /// The type of physical connector used for the jack. /// /// /// The mapping of channels to the jack. /// /// /// For more information, see KSJACK_DESCRIPTION. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksjackdescription-getjackdescription // HRESULT GetJackDescription( UINT nJack, KSJACK_DESCRIPTION *pDescription ); KSJACK_DESCRIPTION GetJackDescription(uint nJack); } /// /// /// The IKsJackDescription2 interface provides information about the jacks or internal connectors that provide a physical /// connection between a device on an audio adapter and an external or internal endpoint device (for example, a microphone or CD player). /// /// /// In addition to getting jack information such as type of connection, the IKsJackDescription is primarily used to report whether /// the jack was connected to the device. In Windows 7, if the connected device driver supports IKsJackDescription2, the /// audio stack or an application can use this interface to get information additional jack information. This includes the jack's /// detection capability and if the format of the device has changed dynamically. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware description parameters in connectors (referred to as KS pins). The IKsJackDescription2 interface provides /// convenient access to the KSPROPERTY_JACK_DESCRIPTION2 property of a connector to an endpoint device. For more information /// about KS properties and KS pins, see the Windows DDK documentation. /// /// /// An application obtains a reference to the IKsJackDescription2 interface of a part by calling the IPart::Activate method /// with parameter refiid set to REFIIDIID_IKsJackDescription2. The call to IPart::Activate succeeds only if /// the part supports the IKsJackDescription2 interface. Only a part object that represents a bridge pin connector on a KS /// filter device topology object supports this interface. /// /// For a code example, see IKsJackDescription. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iksjackdescription2 [PInvokeData("devicetopology.h", MSDNShortId = "9a3d7631-6892-457a-91ab-484ae867fd9f")] [ComImport, Guid("478F3A9B-E0C9-4827-9228-6F5505FFE76A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IKsJackDescription2 { /// /// The GetJackCount method gets the number of jacks on the connector, which are required to connect to an endpoint device. /// /// The number of audio jacks associated with the connector. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksjackdescription2-getjackcount HRESULT // GetJackCount( UINT *pcJacks ); uint GetJackCount(); /// The GetJackDescription2 method gets the description of a specified audio jack. /// /// The index of the jack to get a description for. If the connection consists of n jacks, the jacks are numbered from 0 to n– /// 1. To get the number of jacks, call the IKsJackDescription::GetJackCount method. /// /// /// A structure of type KSJACK_DESCRIPTION2 that contains information about the jack. The buffer size must be at least . /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksjackdescription2-getjackdescription2 // HRESULT GetJackDescription2( UINT nJack, KSJACK_DESCRIPTION2 *pDescription2 ); KSJACK_DESCRIPTION2 GetJackDescription2(uint nJack); } /// /// The IKsJackSinkInformation interface provides access to jack sink information if the jack is supported by the hardware. /// /// The client obtains a reference to the IKsJackSinkInformation interface by activating it on the IPart interface of a /// bridge pin connector on a KS filter device topology object. To activate the object, call the IPart::Activate method with /// parameter refiid set to REFIID IID_IKsJackSinkInformation. /// /// /// Most Windows audio adapter drivers support the Windows Driver Model (WDM) and use kernel-streaming (KS) properties to represent /// the hardware description parameters in connectors (referred to as KS pins). The IKsJackSinkInformation interface provides /// convenient access to the KSPROPERTY_JACK_SINK_INFO property of a connector to an endpoint device. For more information /// about KS properties and KS pins, see the Windows DDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iksjacksinkinformation [PInvokeData("devicetopology.h", MSDNShortId = "4116a912-5ff2-4fc0-96c6-61d1e62cd973")] [ComImport, Guid("D9BD72ED-290F-4581-9FF3-61027A8FE532"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IKsJackSinkInformation { /// The GetJackSinkInformation method retrieves the sink information for the specified jack. /// The sink information of the jack in a KSJACK_SINK_INFORMATION structure. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iksjacksinkinformation-getjacksinkinformation // HRESULT GetJackSinkInformation( KSJACK_SINK_INFORMATION *pJackSinkInformation ); KSJACK_SINK_INFORMATION GetJackSinkInformation(); } /// /// /// The IPart interface represents a part (connector or subunit) of a device topology. A client obtains a reference to an /// IPart interface by calling the IDeviceTopology::GetPartById or IPartsList::GetPart method, or by calling the /// QueryInterface method of the IConnector or ISubunit interface on a part object and setting the method's iid parameter to /// REFIID IID_IPart. /// /// An object with an IPart interface can encapsulate one of the following device topology parts: /// /// /// /// Connector. This is a part that connects to another device to form a data path for transmitting an audio stream between devices. /// /// /// /// Subunit. This is a part that processes an audio stream (for example, volume control). /// /// /// /// The IPart interface of a connector or subunit object represents the generic functions that are common to all parts, and /// the object's IConnector or ISubunit interface represents the functions that are specific to a connector or /// subunit. In addition, a part might support one or more control interfaces for controlling or monitoring the function of the /// part. For example, the client controls a volume-control subunit through its IAudioVolumeLevel interface. /// /// /// The IPart interface provides methods for getting the name, local ID, global ID, and part type of a connector or subunit. /// In addition, IPart can activate a control interface on a connector or subunit. /// /// /// For code examples that use the IPart interface, see the implementations of the GetHardwareDeviceTopology and /// SelectCaptureDevice functions in Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-ipart [PInvokeData("devicetopology.h", MSDNShortId = "3bcfab9f-fad8-4605-8780-0b7c2068fcdf")] [ComImport, Guid("AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPart { /// The GetName method gets the friendly name of this part. /// /// A pointer variable into which the method writes the address of a null-terminated, wide-character string that contains the /// friendly name of this part. The method allocates the storage for the string. If the GetName call fails, *ppwstrName /// is NULL. For information about CoTaskMemFree, see the Windows SDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getname HRESULT GetName( LPWSTR // *ppwstrName ); SafeCoTaskMemString GetName(); /// The GetLocalId method gets the local ID of this part. /// A UINT variable into which the method writes the local ID of this part. /// /// /// When you have a pointer to a part object, you can call this method to get the local ID of the part. A local ID is a number /// that uniquely identifies a part among all parts in a device topology. /// /// /// The IAudioInputSelector::GetSelection and IAudioOutputSelector::GetSelection methods retrieve the local ID of a connected /// part. The IAudioInputSelector::SetSelection and IAudioOutputSelector::SetSelection methods select the input or output that /// is connected to a part that is identified by its local ID. The IDeviceTopology::GetPartById method gets a part that is /// identified by its local ID. /// /// For code examples that use the GetLocalId method, see the following topics: /// /// /// Device Topologies /// /// /// Using the IKsControl Interface to Access Audio Properties /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getlocalid HRESULT GetLocalId( UINT // *pnId ); uint GetLocalId(); /// The GetGlobalId method gets the global ID of this part. /// /// A pointer variable into which the method writes the address of a null-terminated, wide-character string that contains the /// global ID. The method allocates the storage for the string. The caller is responsible for freeing the storage, when it is no /// longer needed, by calling the CoTaskMemFree function. If the GetGlobalId call fails, *ppwstrGlobalId is /// NULL. For information about CoTaskMemFree, see the Windows SDK documentation. /// /// /// A global ID is a string that uniquely identifies a part among all parts in all device topologies in the system. Clients /// should treat this string as opaque. That is, clients should not attempt to parse the contents of the string to obtain /// information about the part. The reason is that the string format is undefined and might change from one implementation of /// the DeviceTopology API to the next. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getglobalid HRESULT GetGlobalId( // LPWSTR *ppwstrGlobalId ); SafeCoTaskMemString GetGlobalId(); /// The GetPartType method gets the part type of this part. /// /// /// A PartType variable into which the method writes the part type. The part type is one of the following PartType /// enumeration values, which indicate whether the part is a connector or subunit: /// /// Connector /// Subunit /// /// /// For a code example that uses this method, see the implementation of the SelectCaptureDevice function in Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getparttype HRESULT GetPartType( // PartType *pPartType ); PartType GetPartType(); /// The GetSubType method gets the part subtype of this part. /// A GUID variable into which the method writes the subtype GUID for this part. /// /// /// This method typically retrieves one of the KSNODETYPE_Xxx GUID values from header file Ksmedia.h, although some custom /// drivers might provide other GUID values. For more information about KSNODETYPE_Xxx GUIDs, see the Windows DDK documentation. /// /// As explained in IPart Interface, a part can be either a connector or a subunit. /// /// For a part that is a connector, this method retrieves the pin-category GUID that the driver has assigned to the connector. /// The following are examples of pin-category GUIDs: /// /// /// /// /// KSNODETYPE_ANALOG_CONNECTOR, if the connector is part of the data path to or from an analog device such as a microphone or speakers. /// /// /// /// KSNODETYPE_SPDIF_INTERFACE, if the connector is part of the data path to or from an S/PDIF port. /// /// /// /// For more information, see the discussion of the pin-category property, KSPROPERTY_PIN_CATEGORY, in the Windows DDK documentation. /// /// /// For a part that is a subunit, this method retrieves a subtype GUID that indicates the stream-processing function that the /// subunit performs. For example, for a volume-control subunit, the method retrieves GUID value KSNODETYPE_VOLUME. /// /// The following table lists some of the subtype GUIDs that can be retrieved by the GetSubType method for a subunit. /// /// /// Subtype GUID /// Control interface /// Required or optional /// /// /// KSNODETYPE_3D_EFFECTS /// IAudioChannelConfig /// Optional /// /// /// KSNODETYPE_AGC /// IAudioAutoGainControl /// Required /// /// /// KSNODETYPE_DAC /// IAudioChannelConfig /// Optional /// /// /// KSNODETYPE_DEMUX /// IAudioOutputSelector /// Required /// /// /// KSNODETYPE_DEV_SPECIFIC /// IDeviceSpecificProperty /// Required /// /// /// KSNODETYPE_LOUDNESS /// IAudioLoudness /// Required /// /// /// KSNODETYPE_MUTE /// IAudioMute /// Required /// /// /// KSNODETYPE_MUX /// IAudioInputSelector /// Required /// /// /// KSNODETYPE_PEAKMETER /// IAudioPeakMeter /// Required /// /// /// KSNODETYPE_PROLOGIC_DECODER /// IAudioChannelConfig /// Optional /// /// /// KSNODETYPE_TONE /// IAudioBass IAudioMidrange IAudioTreble /// OptionalOptional Optional /// /// /// KSNODETYPE_VOLUME /// IAudioChannelConfig IAudioVolumeLevel /// OptionalRequired /// /// /// /// In the preceding table, the middle column lists the control interfaces that are supported by subunits of the subtype /// specified in the left column. The right column indicates whether the subunit's support for a control interface is required /// or optional. If support is required, an application can rely on a subunit of the specified subtype to support the control /// interface. If support is optional, a subunit of the specified subtype can, but does not necessarily, support the control interface. /// /// /// The control interfaces in the preceding table provide convenient access to the properties of subunits. However, some /// subunits have properties for which no corresponding control interfaces exist. Applications can access these properties /// through the IKsControl interface. For more information, see Using the IKsControl Interface to Access Audio Properties. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getsubtype HRESULT GetSubType( GUID // *pSubType ); Guid GetSubType(); /// The GetControlInterfaceCount method gets the number of control interfaces that this part supports. /// A UINT variable into which the method writes the number of control interfaces on this part. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getcontrolinterfacecount HRESULT // GetControlInterfaceCount( UINT *pCount ); uint GetControlInterfaceCount(); /// /// The GetControlInterface method gets a reference to the specified control interface, if this part supports it. /// /// /// The control interface number. If a part supports n control interfaces, the control interfaces are numbered from 0 to n– 1. /// /// /// The IControlInterface interface of the specified audio function. Through this method, the caller obtains a counted reference /// to the interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the /// interface's Release method. If the GetControlInterface call fails, *ppFunction is NULL. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-getcontrolinterface HRESULT // GetControlInterface( UINT nIndex, IControlInterface **ppInterfaceDesc ); IControlInterface GetControlInterface([In] uint nIndex); /// /// The EnumPartsIncoming method gets a list of all the incoming parts—that is, the parts that reside on data paths that /// are upstream from this part. /// /// /// An IPartsList interface that encapsulates the list of parts that are immediately upstream from this part. Through this /// method, the caller obtains a counted reference to the interface. The caller is responsible for releasing the interface, when /// it is no longer needed, by calling the interface's Release method. If the EnumPartsIncoming call fails, /// *ppParts is NULL. /// /// /// /// A client application can traverse a device topology against the direction of audio data flow by iteratively calling this /// method at each step in the traversal to get the list of parts that lie immediately upstream from the current part. /// /// /// If this part has no links to upstream parts, the method returns error code E_NOTFOUND and does not create a parts list /// (*ppParts is NULL). For example, the method returns this error code if the IPart interface represents a /// connector through which data enters a device topology. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-enumpartsincoming HRESULT // EnumPartsIncoming( IPartsList **ppParts ); IPartsList EnumPartsIncoming(); /// /// The EnumPartsOutgoing method retrieves a list of all the outgoing parts—that is, the parts that reside on data paths /// that are downstream from this part. /// /// /// An IPartsList interface that encapsulates the list of parts that are immediately downstream from this part. Through this /// method, the caller obtains a counted reference to the interface. The caller is responsible for releasing the interface, when /// it is no longer needed, by calling the interface's Release method. If the EnumPartsOutgoing call fails, /// *ppParts is NULL. /// /// /// /// A client application can traverse a device topology in the direction of audio data flow by iteratively calling this method /// at each step in the traversal to get the list of parts that lie immediately downstream from the current part. /// /// /// If this part has no links to downstream parts, the method returns error code E_NOTFOUND and does not create a parts list /// (*ppParts is NULL). For example, the method returns this error code if the IPart interface represents a /// connector through which data exits a device topology. /// /// /// For a code example that uses the EnumPartsOutgoing method, see the implementation of the SelectCaptureDevice function /// in Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-enumpartsoutgoing HRESULT // EnumPartsOutgoing( IPartsList **ppParts ); IPartsList EnumPartsOutgoing(); /// /// The GetTopologyObject method gets a reference to the IDeviceTopology interface of the device-topology object that /// contains this part. /// /// /// The IDeviceTopology interface of the device-topology object. The caller obtains a counted reference to the interface /// from this method. Through this method, the caller obtains a counted reference to the interface. The caller is responsible /// for releasing the interface, when it is no longer needed, by calling the interface's Release method. If the /// GetTopologyObject call fails, *ppTopology is NULL. /// /// /// For code examples that use this method, see the following topics: /// /// /// Device Topologies /// /// /// Using the IKsControl Interface to Access Audio Properties /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-gettopologyobject HRESULT // GetTopologyObject( IDeviceTopology **ppTopology ); IDeviceTopology GetTopologyObject(); /// The Activate method activates a function-specific interface on a connector or subunit. /// /// The execution context in which the code that manages the newly created object will run. The caller can restrict the context /// by setting this parameter to the bitwise OR of one or more CLSCTX enumeration values. The client can avoid /// imposing any context restrictions by specifying CLSCTX_ALL. For more information about CLSCTX, see the Windows SDK documentation. /// /// /// /// The interface ID for the requested control function. The client should set this parameter to one of the following /// REFIID values: /// /// IID_IAudioAutoGainControl /// IID_IAudioBass /// IID_IAudioChannelConfig /// IID_IAudioInputSelector /// IID_IAudioLoudness /// IID_IAudioMidrange /// IID_IAudioMute /// IID_IAudioOutputSelector /// IID_IAudioPeakMeter /// IID_IAudioTreble /// IID_IAudioVolumeLevel /// IID_IDeviceSpecificProperty /// IID_IKsFormatSupport /// IID_IKsJackDescription /// For more information, see Remarks. /// /// /// The interface that is specified by parameter refiid. Through this method, the caller obtains a counted reference to the /// interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's /// Release method. If the Activate call fails, *ppObject is NULL. /// /// /// The Activate method supports the following function-specific control interfaces: /// /// /// IAudioAutoGainControl /// /// /// IAudioBass /// /// /// IAudioChannelConfig /// /// /// IAudioInputSelector /// /// /// IAudioLoudness /// /// /// IAudioMidrange /// /// /// IAudioMute /// /// /// IAudioOutputSelector /// /// /// IAudioPeakMeter /// /// /// IAudioTreble /// /// /// IAudioVolumeLevel /// /// /// IDeviceSpecificProperty /// /// /// IKsFormatSupport /// /// /// IKsJackDescription /// /// /// /// To obtain the interface ID of the function-specific control interface of a part, call the part's IControlInterface::GetIID /// method. To obtain the interface ID of a function-specific control interface type, use the __uuidof operator. For /// example, the interface ID of IAudioAutoGainControl is defined as follows: /// /// For more information about the __uuidof operator, see the Windows SDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-activate HRESULT Activate( DWORD // dwClsContext, REFIID refiid, void **ppvObject ); [return: MarshalAs(UnmanagedType.IUnknown)] object Activate([In] CLSCTX dwClsContext, in Guid refiid); /// /// The RegisterControlChangeCallback method registers the IControlChangeNotify interface, which the client implements to /// receive notifications of status changes in this part. /// /// /// The function-specific control interface that is to be monitored for control changes. For more information, see Remarks. /// /// /// Pointer to the client's IControlChangeNotify interface. If the method succeeds, it calls the AddRef method on the client's /// IControlChangeNotify interface. /// /// /// Set parameter riid to one of the following GUID values: /// /// /// IID_IAudioAutoGainControl /// /// /// IID_IAudioBass /// /// /// IID_IAudioChannelConfig /// /// /// IID_IAudioInputSelector /// /// /// IID_IAudioLoudness /// /// /// IID_IAudioMidrange /// /// /// IID_IAudioMute /// /// /// IID_IAudioOutputSelector /// /// /// IID_IAudioPeakMeter /// /// /// IID_IAudioTreble /// /// /// IID_IAudioVolumeLevel /// /// /// IID_IDeviceSpecificProperty /// /// /// IID_IKsFormatSupport /// /// /// IID_IKsJackDescription /// /// /// /// To obtain the interface ID of the function-specific control interface for a part, call the part's IControlInterface::GetIID /// method. To obtain the interface ID of a function-specific control interface type, use the __uuidof operator. For /// example, the interface ID of IAudioAutoGainControl is defined as follows: /// /// For more information about the __uuidof operator, see the Windows SDK documentation. /// /// Before the client releases its final reference to the IControlChangeNotify interface, it should call the /// IPart::UnregisterControlChangeCallback method to unregister the interface. Otherwise, the application leaks the resources /// held by the IControlChangeNotify and IPart objects. Note that RegisterControlChangeCallback calls the client's /// IControlChangeNotify::AddRef method, and UnregisterControlChangeCallback calls the IControlChangeNotify::Release /// method. If the client errs by releasing its reference to the IControlChangeNotify interface before calling /// UnregisterControlChangeCallback, the IPart object never releases its reference to the /// IControlChangeNotify interface. For example, a poorly designed IControlChangeNotify implementation might call /// UnregisterControlChangeCallback from the destructor for the IControlChangeNotify object. In this case, the /// client will not call UnregisterControlChangeCallback until the IPart object releases its reference to the /// IControlChangeNotify interface, and the IPart object will not release its reference to the /// IControlChangeNotify interface until the client calls UnregisterControlChangeCallback. For more information /// about the AddRef and Release methods, see the discussion of the IUnknown interface in the Windows SDK documentation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-registercontrolchangecallback // HRESULT RegisterControlChangeCallback( REFGUID riid, IControlChangeNotify *pNotify ); void RegisterControlChangeCallback(in Guid riid, [In] IControlChangeNotify pNotify); /// /// The UnregisterControlChangeCallback method removes the registration of an IControlChangeNotify interface that the /// client previously registered by a call to the IPart::RegisterControlChangeCallback method. /// /// /// Pointer to the IControlChangeNotify interface whose registration is to be deleted. The client passed this same /// interface pointer to the part object in a previous call to the IPart::RegisterControlChangeCallback method. If the /// UnregisterControlChangeCallback method succeeds, it calls the Release method on the client's /// IControlChangeNotify interface. /// /// /// Before the client releases its final reference to the IControlChangeNotify interface, it should call /// UnregisterControlChangeCallback to unregister the interface. Otherwise, the application leaks the resources held by /// the IControlChangeNotify and IPart objects. Note that the IPart::RegisterControlChangeCallback method /// calls the client's IControlChangeNotify::AddRef method, and UnregisterControlChangeCallback calls the /// IControlChangeNotify::Release method. If the client errs by releasing its reference to the /// IControlChangeNotify interface before calling UnregisterControlChangeCallback, the IPart object never /// releases its reference to the IControlChangeNotify interface. For example, a poorly designed /// IControlChangeNotify implementation might call UnregisterControlChangeCallback from the destructor for the /// IControlChangeNotify object. In this case, the client will not call UnregisterControlChangeCallback until the /// IPart object releases its reference to the IControlChangeNotify interface, and the IPart object will /// not release its reference to the IControlChangeNotify interface until the client calls /// UnregisterControlChangeCallback. For more information about the AddRef and Release methods, see the /// discussion of the IUnknown interface in the Windows SDK documentation. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipart-unregistercontrolchangecallback // HRESULT UnregisterControlChangeCallback( IControlChangeNotify *pNotify ); void UnregisterControlChangeCallback([In] IControlChangeNotify pNotify); } /// /// The Activate method activates a function-specific interface on a connector or subunit. /// /// The type of the interface for the requested control function. /// The part. /// The execution context in which the code that manages the newly created object will run. The caller can restrict the context /// by setting this parameter to the bitwise OR of one or more CLSCTX enumeration values. The client can avoid /// imposing any context restrictions by specifying CLSCTX_ALL. For more information about CLSCTX, see the Windows SDK documentation. /// /// The interface that is specified by . Through this method, the caller obtains a counted reference to the /// interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's /// Release method. If the Activate call fails, *ppObject is NULL. /// /// /// The Activate method supports the following function-specific control interfaces: /// /// /// IAudioAutoGainControl /// /// /// IAudioBass /// /// /// IAudioChannelConfig /// /// /// IAudioInputSelector /// /// /// IAudioLoudness /// /// /// IAudioMidrange /// /// /// IAudioMute /// /// /// IAudioOutputSelector /// /// /// IAudioPeakMeter /// /// /// IAudioTreble /// /// /// IAudioVolumeLevel /// /// /// IDeviceSpecificProperty /// /// /// IKsFormatSupport /// /// /// IKsJackDescription /// /// /// public static T Activate(this IPart part, [In] CLSCTX dwClsContext = CLSCTX.CLSCTX_ALL) where T : class => part.Activate(dwClsContext, typeof(T).GUID) as T; /// /// /// The IPartsList interface represents a list of parts, each of which is an object with an IPart interface that represents a /// connector or subunit. A client obtains a reference to an IPartsList interface by calling the IPart::EnumPartsIncoming, /// IPart::EnumPartsOutgoing, or IDeviceTopology::GetSignalPath method. /// /// /// For a code example that uses the IPartsList interface, see the implementation of the SelectCaptureDevice function in /// Device Topologies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-ipartslist [PInvokeData("devicetopology.h", MSDNShortId = "3ac48781-90c2-4b23-aa68-3453091bde61")] [ComImport, Guid("6DAA848C-5EB0-45CC-AEA5-998A2CDA1FFB"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPartsList { /// The GetCount method gets the number of parts in the parts list. /// A UINT variable into which the method writes the parts count (the number of parts in the parts list). // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipartslist-getcount HRESULT GetCount( // UINT *pCount ); uint GetCount(); /// The GetPart method gets a part from the parts list. /// /// The part number of the part to retrieve. If the parts list contains n parts, the parts are numbered 0 to n– 1. Call the /// IPartsList::GetCount method to get the number of parts in the list. /// /// /// The IPart interface of the part object. Through this method, the caller obtains a counted reference to the IPart /// interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's /// Release method. If the GetPart call fails, *ppPart is NULL. /// /// /// For a code example that calls the GetPart method, see the implementation of the SelectCaptureDevice function in /// Device Topologies. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-ipartslist-getpart HRESULT GetPart( UINT // nIndex, IPart **ppPart ); IPart GetPart([In] uint nIndex); } /// /// /// The IPerChannelDbLevel interface represents a generic subunit control interface that provides per-channel control over /// the volume level, in decibels, of an audio stream or of a frequency band in an audio stream. A positive volume level represents /// gain, and a negative value represents attenuation. /// /// /// Clients do not call the methods in this interface directly. Instead, this interface serves as the base interface for the /// following interfaces, which clients do call directly: /// /// /// /// IAudioBass Interface /// /// /// IAudioMidrange Interface /// /// /// IAudioTreble Interface /// /// /// IAudioVolumeLevel Interface /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-iperchanneldblevel [ComImport, Guid("C2F8E001-F205-4BC9-99BC-C13B1E048CCB"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPerChannelDbLevel { /// The GetChannelCount method gets the number of channels in the audio stream. /// A UINT variable into which the method writes the channel count (the number of channels in the audio stream). // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getchannelcount // HRESULT GetChannelCount( UINT *pcChannels ); uint GetChannelCount(); /// The GetLevelRange method gets the range, in decibels, of the volume level of the specified channel. /// /// The number of the selected channel. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// Pointer to a float variable into which the method writes the minimum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the maximum volume level in decibels. /// /// /// Pointer to a float variable into which the method writes the stepping value between consecutive volume levels in the /// range *pfMinLevelDB to *pfMaxLevelDB. If the difference between the maximum and minimum volume levels is d decibels, and the /// range is divided into n steps (uniformly sized intervals), then the volume can have n + 1 discrete levels and the size of /// the step between consecutive levels is d / n decibels. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevelrange HRESULT // GetLevelRange( UINT nChannel, float *pfMinLevelDB, float *pfMaxLevelDB, float *pfStepping ); void GetLevelRange([In] uint nChannel, out float pfMinLevelDB, out float pfMaxLevelDB, out float pfStepping); /// The GetLevel method gets the volume level, in decibels, of the specified channel. /// /// The channel number. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the number of /// channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// A float variable into which the method writes the volume level, in decibels, of the specified channel. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-getlevel HRESULT // GetLevel( UINT nChannel, float *pfLevelDB ); float GetLevel([In] uint nChannel); /// The SetLevel method sets the volume level, in decibels, of the specified channel. /// /// The number of the selected channel. If the audio stream has N channels, the channels are numbered from 0 to N– 1. To get the /// number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The new volume level in decibels. A positive value represents gain, and a negative value represents attenuation. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevel call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// /// If the caller specifies a value for fLevelDB that is an exact stepping value, the SetLevel method completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method will return either the value that was set, or one /// of the following values: /// /// /// /// If the set value was below the minimum, the GetLevel method returns the minimum value. /// /// /// If the set value was above the maximum, the GetLevel method returns the maximum value. /// /// /// /// If the set value was between two stepping values, the GetLevel method returns a value that could be the next stepping /// value above or the stepping value below the set value; the relative distances from the set value to the neighboring stepping /// values is unimportant. The value that the GetLevel method returns is whichever value has more of an impact on the /// signal path. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevel HRESULT // SetLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); void SetLevel([In] uint nChannel, [In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelUniform method sets all channels in the audio stream to the same uniform volume level, in decibels. /// /// The new uniform level in decibels. /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelUniform call changes the state of the level control, all clients that have registered IControlChangeNotify /// interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer. /// /// /// If the specified uniform level is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports for a /// particular channel, the SetLevelUniform call clamps the value for that channel to the supported range and completes /// successfully. A subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setleveluniform // HRESULT SetLevelUniform( float fLevelDB, LPCGUID pguidEventContext ); void SetLevelUniform([In] float fLevelDB, [Optional] in Guid pguidEventContext); /// /// The SetLevelAllChannels method sets the volume levels, in decibels, of all the channels in the audio stream. /// /// /// Pointer to an array of volume levels. This parameter points to a caller-allocated float array into which the method /// writes the new volume levels, in decibels, for all the channels. The method writes the level for a particular channel into /// the array element whose index matches the channel number. If the audio stream contains n channels, the channels are numbered /// 0 to n– 1. To get the number of channels in the stream, call the IPerChannelDbLevel::GetChannelCount method. /// /// /// The number of elements in the aLevelsDB array. If this parameter does not match the number of channels in the audio stream, /// the method fails without modifying the aLevelsDB array. /// /// /// Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the /// SetLevelAllChannels call changes the state of the level control, all clients that have registered /// IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify /// method, a client can inspect the event-context GUID to discover whether it or another client is the source of the /// control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method /// receives a NULL context pointer. /// /// /// If the specified level value for any channel is beyond the range that the IPerChannelDbLevel::GetLevelRange method reports /// for that channel, the SetLevelAllChannels call clamps the value to the supported range and completes successfully. A /// subsequent call to the IPerChannelDbLevel::GetLevel method retrieves the actual value used for that channel. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nf-devicetopology-iperchanneldblevel-setlevelallchannels // HRESULT SetLevelAllChannels( float [] aLevelsDB, ULONG cChannels, LPCGUID pguidEventContext ); void SetLevelAllChannels([In, MarshalAs(UnmanagedType.LPArray)] float[] aLevelsDB, [In] uint cChannels, [Optional] in Guid pguidEventContext); } /// /// The ISubunit interface represents a hardware subunit (for example, a volume control) that lies in the data path between a /// client and an audio endpoint device. The client obtains a reference to an ISubunit interface by calling the /// IDeviceTopology::GetSubunit method, or by calling the IPart::QueryInterface method with parameter iid set to /// REFIID IID_ISubunit. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/nn-devicetopology-isubunit [PInvokeData("devicetopology.h", MSDNShortId = "9ec630bc-bba1-4a44-b66d-404a5221abbf")] [ComImport, Guid("82149A85-DBA6-4487-86BB-EA8F7FEFCC71"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ISubunit { } /// The KSJACK_DESCRIPTION structure describes an audio jack. /// /// This structure is used by the IKsJackDescription::GetJackDescription method in the DeviceTopology API. It describes an audio /// jack that is part of a connection between an endpoint device and a hardware device in an audio adapter. When a user needs to /// plug an endpoint device into a jack or unplug it from a jack, an audio application can use the descriptive information in the /// structure to help the user to find the jack. /// // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/ns-devicetopology-ksjack_description typedef struct // __MIDL___MIDL_itf_devicetopology_0000_0000_0009 { DWORD ChannelMapping; COLORREF Color; EPcxConnectionType ConnectionType; // EPcxGeoLocation GeoLocation; EPcxGenLocation GenLocation; EPxcPortConnection PortConnection; BOOL IsConnected; } // KSJACK_DESCRIPTION, *PKSJACK_DESCRIPTION; [PInvokeData("devicetopology.h", MSDNShortId = "4ee9fedf-4241-4678-b621-549a06e8949a")] [StructLayout(LayoutKind.Sequential)] public struct KSJACK_DESCRIPTION { /// /// Specifies the mapping of the two audio channels in a stereo jack to speaker positions. /// /// In Windows Vista, the value of this member is one of the EChannelMapping enumeration values shown in the following table. /// /// For a physical connector with one, three, or more channels, the value of this member is ePcxChanMap_Unknown. /// /// In Windows 7, the EChannelMapping enumeration has been deprecated. The datatype of this member is a DWORD. /// This member stores either 0 or the bitwise-OR combination of one or more of the following values that are defined in Ksmedia.h. /// /// public ChannelMapping ChannelMapping; /// /// The jack color. The color is expressed as a 32-bit RGB value that is formed by concatenating the 8-bit blue, green, and red /// color components. The blue component occupies the 8 least-significant bits (bits 0-7), the green component occupies bits /// 8-15, and the red component occupies bits 16-23. The 8 most-significant bits are zeros. If the jack color is unknown or the /// physical connector has no identifiable color, the value of this member is 0x00000000, which is black. /// public COLORREF Color; /// /// /// The connection type. The value of this member is one of the EPcxConnectionType enumeration values shown in the /// following table. /// /// /// /// Value /// Connector type /// /// /// eConnTypeUnknown /// Unknown /// /// /// eConnTypeEighth (Windows Vista) eConnType3Point5mm (Windows 7) /// /// 1/8-inch jack /// /// /// eConnTypeQuarter /// 1/4-inch jack /// /// /// eConnTypeAtapiInternal /// ATAPI internal connector /// /// /// eConnTypeRCA /// RCA jack /// /// /// eConnTypeOptical /// Optical connector /// /// /// eConnTypeOtherDigital /// Generic digital connector /// /// /// eConnTypeOtherAnalog /// Generic analog connector /// /// /// eConnTypeMultichannelAnalogDIN /// Multichannel analog DIN connector /// /// /// eConnTypeXlrProfessional /// XLR connector /// /// /// eConnTypeRJ11Modem /// RJ11 modem connector /// /// /// eConnTypeCombination /// Combination of connector types /// /// /// public EPcxConnectionType ConnectionType; /// /// /// The geometric location of the jack. The value of this member is one of the EPcxGeoLocation enumeration values shown /// in the following table. /// /// /// /// Value /// Geometric location /// /// /// eGeoLocRear /// Rear-mounted panel /// /// /// eGeoLocFront /// Front-mounted panel /// /// /// eGeoLocLeft /// Left-mounted panel /// /// /// eGeoLocRight /// Right-mounted panel /// /// /// eGeoLocTop /// Top-mounted panel /// /// /// eGeoLocBottom /// Bottom-mounted panel /// /// /// eGeoLocRearOPanel(Windows Vista) eGeoLocRearPanel(Windows 7) /// Rear slide-open or pull-open panel /// /// /// eGeoLocRiser /// Riser card /// /// /// eGeoLocInsideMobileLid /// Inside lid of mobile computer /// /// /// eGeoLocDrivebay /// Drive bay /// /// /// eGeoLocHDMI /// HDMI connector /// /// /// eGeoLocOutsideMobileLid /// Outside lid of mobile computer /// /// /// eGeoLocATAPI /// ATAPI connector /// /// /// public EPcxGeoLocation GeoLocation; /// /// /// The general location of the jack. The value of this member is one of the EPcxGenLocation enumeration values shown in /// the following table. /// /// /// /// Value /// General location /// /// /// eGenLocPrimaryBox /// On primary chassis /// /// /// eGenLocInternal /// Inside primary chassis /// /// /// eGenLocSeperate(Windows Vista) eGenLocSeparate(Windows 7) /// On separate chassis /// /// /// eGenLocOther /// Other location /// /// /// public EPcxGenLocation GenLocation; /// /// /// The type of port represented by the jack. The value of this member is one of the EPxcPortConnection enumeration /// values shown in the following table. /// /// /// /// Value /// Port connection type /// /// /// ePortConnJack /// Jack /// /// /// ePortConnIntegratedDevice /// Slot for an integrated device /// /// /// ePortConnBothIntegratedAndJack /// Both a jack and a slot for an integrated device /// /// /// ePortConnUnknown /// Unknown /// /// /// public EPxcPortConnection PortConnection; /// /// If the audio adapter supports jack-presence detection on the jack, the value of IsConnected indicates whether an /// endpoint device is plugged into the jack. If IsConnected is TRUE, a device is plugged in. If it is /// FALSE, the jack is empty. For devices that do not support jack-presence detection, this member is always TRUE. /// For more information about jack-presence detection, see Audio Endpoint Devices. /// [MarshalAs(UnmanagedType.Bool)] public bool IsConnected; } /// The structure specifies the capabilities and the current state of a jack that supports jack presence detection. /// /// If an audio device lacks jack presence detection, the IsConnected member of the KSJACK_DESCRIPTION structure must /// always be set to TRUE. To remove the ambiguity that results from this dual meaning of the TRUE value for /// IsConnected, a client application can call IKsJackDescription2::GetJackDescription2 to read the JackCapabilities /// flag of the structure. If this flag has the JACKDESC2_PRESENCE_DETECT_CAPABILITY bit set, it indicates that the endpoint does in /// fact support jack presence detection. In that case, the return value of the IsConnected member can be interpreted to /// accurately reflect the insertion status of the jack. /// // https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/ksjack-description2 typedef struct _tagKSJACK_DESCRIPTION2 { // DWORD DeviceStateInfo; DWORD JackCapabilities; } KSJACK_DESCRIPTION2, *PKSJACK_DESCRIPTION2; [PInvokeData("Ksmedia.h", MSDNShortId = "0db29870-20d0-459b-a531-3dea5d073183")] [StructLayout(LayoutKind.Sequential)] public struct KSJACK_DESCRIPTION2 { /// /// Specifies the lower 16 bits of the DWORD parameter. This parameter indicates whether the jack is currently active, /// streaming, idle, or hardware not ready. /// public uint DeviceStateInfo; /// /// /// Specifies the lower 16 bits of the DWORD parameter. This parameter is a flag and it indicates the capabilities of the jack. /// This flag can be set to one of the values in the following table. /// /// /// /// Flag /// Meaning /// /// /// JACKDESC2_PRESENCE_DETECT_CAPABILITY (0x00000001) /// Jack supports jack presence detection. /// /// /// JACKDESC2_DYNAMIC_FORMAT_CHANGE_CAPABILITY (0x00000002) /// Jack supports dynamic format change. /// /// /// For more information about dynamic format change, see Dynamic Format Change. /// public JackCapabilities JackCapabilities; } /// The KSJACK_SINK_INFORMATION structure stores information about an audio jack sink. // https://docs.microsoft.com/en-us/windows/win32/api/devicetopology/ns-devicetopology-ksjack_sink_information typedef struct // _tagKSJACK_SINK_INFORMATION { KSJACK_SINK_CONNECTIONTYPE ConnType; WORD ManufacturerId; WORD ProductId; WORD AudioLatency; BOOL // HDCPCapable; BOOL AICapable; UCHAR SinkDescriptionLength; WCHAR SinkDescription[32]; LUID PortId; } KSJACK_SINK_INFORMATION; [PInvokeData("devicetopology.h", MSDNShortId = "ee7211d8-a34f-40c9-9925-7bb40792bae9")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct KSJACK_SINK_INFORMATION { /// Specifies the type of connection. The connection type values are defined in the KSJACK_SINK_CONNECTIONTYPE enumeration. public KSJACK_SINK_CONNECTIONTYPE ConnType; /// Specifies the sink manufacturer identifier. public ushort ManufacturerId; /// Specifies the sink product identifier. public ushort ProductId; /// Specifies the latency of the audio sink. public ushort AudioLatency; /// Specifies whether the sink supports High-bandwidth Digital Content Protection (HDCP). [MarshalAs(UnmanagedType.Bool)] public bool HDCPCapable; /// Specifies whether the sink supports ACP Packet, ISRC1, or ISRC2. [MarshalAs(UnmanagedType.Bool)] public bool AICapable; /// Specifies the length of the string in the SinkDescription member. public byte SinkDescriptionLength; /// /// String containing the monitor sink name. The maximum length is defined by the constant /// MAX_SINK_DESCRIPTION_NAME_LENGTH (32 wide characters). /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string SinkDescription; /// Specifies the video port identifier in a LUID structure. public LUID PortId; } } }