-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
346 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using NAudio.CoreAudioApi.Interfaces; | ||
|
||
namespace NAudio.CoreAudioApi | ||
{ | ||
/// <summary> | ||
/// Connector | ||
/// </summary> | ||
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace NAudio.CoreAudioApi | ||
{ | ||
/// <summary> | ||
/// Connector Type | ||
/// </summary> | ||
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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
/// <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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace NAudio.CoreAudioApi.Interfaces | ||
{ | ||
[Guid("82149A85-DBA6-4487-86BB-EA8F7FEFCC71"), | ||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | ||
ComImport] | ||
internal interface ISubunit | ||
{ | ||
// Stub, Not Implemented | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.