frgnca / AudioDeviceCmdlets

AudioDeviceCmdlets is a suite of PowerShell Cmdlets to control audio devices on Windows
MIT License
764 stars 92 forks source link

Get devices from a try-catch #55

Closed frgnca closed 2 years ago

frgnca commented 2 years ago

This will make sure not to end in error anymore when there is not at least one enabled device to take the default and default communication role for both type.

TODO:

DONE:

try
{
    var = DevEnum.EnumerateAudioEndPoints(EDataFlow, EDeviceState);
}
catch { }
try
{
    var = DevEnum.GetDefaultAudioEndpoint(EDataFlow, ERole);
}
catch { }
God-damnit-all commented 2 years ago

I recommend adding a Write-Debug message in each of the catches.

Though, I've got to say, I'm a little concerned that there hasn't been a new version yet. I've seen this before, where a developer won't release a new version until every possible bug is fixed, but gets burnt out before finishing...

frgnca commented 2 years ago

I recommend adding a Write-Debug message in each of the catches.

I do intend to throw an exception in most of them, but for some I need the execution to just continue. One of those situations is when the software tries internally to get the ID of, say, the default communication playback device, which might not exist. Like in this current part of the code https://github.com/frgnca/AudioDeviceCmdlets/blob/d9dc7886121127a4dbdcabed962e21c0cfa76e89/SOURCE/AudioDeviceCmdlets.cs#L147-L179