mirror of https://github.com/naudio/NAudio.git
Browse Source
Merge branch 'devicetop' of https://github.com/pix64/NAudio into pix64-devicetop
pull/515/head
Merge branch 'devicetop' of https://github.com/pix64/NAudio into pix64-devicetop
pull/515/head

10 changed files with 346 additions and 0 deletions
-
105NAudio/CoreAudioApi/Connector.cs
-
34NAudio/CoreAudioApi/ConnectorType.cs
-
54NAudio/CoreAudioApi/DeviceTopology.cs
-
26NAudio/CoreAudioApi/Interfaces/IConnector.cs
-
25NAudio/CoreAudioApi/Interfaces/IDeviceTopology.cs
-
19NAudio/CoreAudioApi/Interfaces/IPart.cs
-
20NAudio/CoreAudioApi/Interfaces/IPartsList.cs
-
15NAudio/CoreAudioApi/Interfaces/ISubunit.cs
-
44NAudio/CoreAudioApi/MMDevice.cs
-
4NAudio/CoreAudioApi/PropertyKeys.cs
@ -0,0 +1,105 @@ |
|||
using NAudio.CoreAudioApi.Interfaces; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi |
|||
{ |
|||
public class Connector |
|||
{ |
|||
private readonly IConnector connectorInterface; |
|||
|
|||
internal Connector(IConnector connector) |
|||
{ |
|||
connectorInterface = connector; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Connects this connector to a connector in another device-topology object
|
|||
/// </summary>
|
|||
public void ConnectTo(Connector other) |
|||
{ |
|||
connectorInterface.ConnectTo(other.connectorInterface); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retreives the type of this connector
|
|||
/// </summary>
|
|||
public ConnectorType Type |
|||
{ |
|||
get |
|||
{ |
|||
connectorInterface.GetType(out var result); |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retreives the data flow of this connector
|
|||
/// </summary>
|
|||
public DataFlow DataFlow |
|||
{ |
|||
get |
|||
{ |
|||
connectorInterface.GetDataFlow(out var result); |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Disconnects this connector from it's connected connector (if connected)
|
|||
/// </summary>
|
|||
public void Disconnect() |
|||
{ |
|||
connectorInterface.Disconnect(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Indicates whether this connector is connected to another connector
|
|||
/// </summary>
|
|||
public bool IsConnected |
|||
{ |
|||
get |
|||
{ |
|||
connectorInterface.IsConnected(out var result); |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retreives the connector this connector is connected to (if connected)
|
|||
/// </summary>
|
|||
public Connector ConnectedTo |
|||
{ |
|||
get |
|||
{ |
|||
connectorInterface.GetConnectedTo(out var result); |
|||
return new Connector(result); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retreives the global ID of the connector this connector is connected to (if connected)
|
|||
/// </summary>
|
|||
public string ConnectedToConnectorId |
|||
{ |
|||
get |
|||
{ |
|||
connectorInterface.GetConnectorIdConnectedTo(out var result); |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retreives the device ID of the audio device this connector is connected to (if connected)
|
|||
/// </summary>
|
|||
public string ConnectedToDeviceId |
|||
{ |
|||
get |
|||
{ |
|||
connectorInterface.GetDeviceIdConnectedTo(out var result); |
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi |
|||
{ |
|||
public enum ConnectorType |
|||
{ |
|||
/// <summary>
|
|||
/// The connector is part of a connection of unknown type.
|
|||
/// </summary>
|
|||
UnknownConnector, |
|||
/// <summary>
|
|||
/// The connector is part of a physical connection to an auxiliary device that is installed inside the system chassis
|
|||
/// </summary>
|
|||
PhysicalInternal, |
|||
/// <summary>
|
|||
/// The connector is part of a physical connection to an external device.
|
|||
/// </summary>
|
|||
PhysicalExternal, |
|||
/// <summary>
|
|||
/// 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.
|
|||
/// </summary>
|
|||
SoftwareIo, |
|||
/// <summary>
|
|||
/// The connector is part of a permanent connection that is fixed and cannot be configured under software control.
|
|||
/// </summary>
|
|||
SoftwareFixed, |
|||
/// <summary>
|
|||
/// The connector is part of a connection to a network.
|
|||
/// </summary>
|
|||
Network, |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
using NAudio.CoreAudioApi.Interfaces; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi |
|||
{ |
|||
/// <summary>
|
|||
/// Windows CoreAudio DeviceTopology
|
|||
/// </summary>
|
|||
public class DeviceTopology |
|||
{ |
|||
private readonly IDeviceTopology deviceTopologyInterface; |
|||
|
|||
internal DeviceTopology(IDeviceTopology deviceTopology) |
|||
{ |
|||
deviceTopologyInterface = deviceTopology; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retrieves the number of connections associated with this device-topology object
|
|||
/// </summary>
|
|||
public uint ConnectorCount |
|||
{ |
|||
get |
|||
{ |
|||
deviceTopologyInterface.GetConnectorCount(out var count); |
|||
return count; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retrieves the connector at the supplied index
|
|||
/// </summary>
|
|||
public Connector GetConnector(uint index) |
|||
{ |
|||
deviceTopologyInterface.GetConnector(index, out var connectorInterface); |
|||
return new Connector(connectorInterface); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retrieves the device id of the device represented by this device-topology object
|
|||
/// </summary>
|
|||
public string DeviceId |
|||
{ |
|||
get |
|||
{ |
|||
deviceTopologyInterface.GetDeviceId(out var result); |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi.Interfaces |
|||
{ |
|||
/// <summary>
|
|||
/// Windows CoreAudio IConnector interface
|
|||
/// Defined in devicetopology.h
|
|||
/// </summary>
|
|||
[Guid("9C2C4058-23F5-41DE-877A-DF3AF236A09E"), |
|||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), |
|||
ComImport] |
|||
internal interface IConnector |
|||
{ |
|||
int GetType(out ConnectorType type); |
|||
int GetDataFlow(out DataFlow flow); |
|||
int ConnectTo([In] IConnector connectTo); |
|||
int Disconnect(); |
|||
int IsConnected(out bool connected); |
|||
int GetConnectedTo(out IConnector conTo); |
|||
int GetConnectorIdConnectedTo([MarshalAs(UnmanagedType.LPWStr)] out string id); |
|||
int GetDeviceIdConnectedTo([MarshalAs(UnmanagedType.LPWStr)] out string id); |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi.Interfaces |
|||
{ |
|||
/// <summary>
|
|||
/// Windows CoreAudio IDeviceTopology interface
|
|||
/// Defined in devicetopology.h
|
|||
/// </summary>
|
|||
[Guid("2A07407E-6497-4A18-9787-32F79BD0D98F"), |
|||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), |
|||
ComImport] |
|||
internal interface IDeviceTopology |
|||
{ |
|||
int GetConnectorCount(out uint count); |
|||
int GetConnector(uint index, out IConnector connector); |
|||
int GetSubunitCount(out uint count); |
|||
int GetSubunit(uint index, out ISubunit subunit); |
|||
int GetPartById(uint id, out IPart part); |
|||
int GetDeviceId([MarshalAs(UnmanagedType.LPWStr)] out string id); |
|||
int GetSignalPath(IPart from, IPart to, bool rejectMixedPaths, out IPartsList parts); |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi.Interfaces |
|||
{ |
|||
/// <summary>
|
|||
/// Windows CoreAudio IPart interface
|
|||
/// Defined in devicetopology.h
|
|||
/// </summary>
|
|||
[Guid("AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9"), |
|||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), |
|||
ComImport] |
|||
internal interface IPart |
|||
{ |
|||
// Stub, Not implemented
|
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi.Interfaces |
|||
{ |
|||
/// <summary>
|
|||
/// Windows CoreAudio IPartsList interface
|
|||
/// Defined in devicetopology.h
|
|||
/// </summary>
|
|||
[Guid("6DAA848C-5EB0-45CC-AEA5-998A2CDA1FFB"), |
|||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), |
|||
ComImport] |
|||
internal interface IPartsList |
|||
{ |
|||
int GetCount(out uint count); |
|||
int GetPart(uint index, out IPart part); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
|
|||
namespace NAudio.CoreAudioApi.Interfaces |
|||
{ |
|||
[Guid("82149A85-DBA6-4487-86BB-EA8F7FEFCC71"), |
|||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), |
|||
ComImport] |
|||
internal interface ISubunit |
|||
{ |
|||
// Stub, Not Implemented
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue