Public Access
Archive completed meeting assistant changes
PR and Push Build/Test / build-and-test (push) Successful in 9m19s
PR and Push Build/Test / build-and-test (push) Successful in 9m19s
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
namespace MeetingAssistant.Recording;
|
||||
|
||||
public sealed class MicrophoneDeviceSelection
|
||||
{
|
||||
private readonly object sync = new();
|
||||
private string? selectedDeviceId;
|
||||
|
||||
public string? SelectedDeviceId
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
return selectedDeviceId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Select(string deviceId)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
selectedDeviceId = string.IsNullOrWhiteSpace(deviceId)
|
||||
? null
|
||||
: deviceId.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public MicrophoneDevice? Resolve(
|
||||
string? configuredDeviceId,
|
||||
MicrophoneDevice? defaultDevice,
|
||||
IReadOnlyList<MicrophoneDevice> availableDevices)
|
||||
{
|
||||
var selected = SelectedDeviceId;
|
||||
return FindById(availableDevices, selected) ??
|
||||
FindById(availableDevices, configuredDeviceId) ??
|
||||
defaultDevice;
|
||||
}
|
||||
|
||||
private static MicrophoneDevice? FindById(
|
||||
IReadOnlyList<MicrophoneDevice> devices,
|
||||
string? id)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return devices.FirstOrDefault(device => string.Equals(
|
||||
device.Id,
|
||||
id.Trim(),
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user