Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for device state (Enabled = true/false) #25

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion SOURCE/AudioDeviceCmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public bool IsDefaultCommunication(string ID)
public class GetAudioDevice : Cmdlet
{
// Parameter called to list all devices
[Parameter(Mandatory = true, Position = 0, ParameterSetName = "List")]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = "ShowDisabled")]
public SwitchParameter List
{
get { return list; }
Expand Down Expand Up @@ -360,6 +360,25 @@ protected override void ProcessRecord()
WriteObject(new AudioDevice(i + 1, DeviceCollection[i], Toolkit.IsDefault(DeviceCollection[i].ID), Toolkit.IsDefaultCommunication(DeviceCollection[i].ID)));
}

// If the ShowDisabled parameter was called
if (showdisabled)
{
// The ShowDisabled parameter was called

// Get enabled DeviceCollection count
int enabledCount = DeviceCollection.Count;

// Get MMDeviceCollection of every disabled devices
DeviceCollection = DevEnum.EnumerateAudioEndPoints(EDataFlow.eAll, EDeviceState.DEVICE_STATE_UNPLUGGED);

// For every MMDevice in DeviceCollection
for (int i = 0; i < DeviceCollection.Count; i++)
{
// Output the result of the creation of a new AudioDevice while assining it an index, and the MMDevice itself
WriteObject(new AudioDevice(i + 1 + enabledCount, DeviceCollection[i]));
}
}

// Stop checking for other parameters
return;
}
Expand Down