- introduce controllable collector

master
Simon G 5 years ago
parent 64002b3332
commit 610334404d
  1. 28
      Lib.Audio/ControllableCollector.cs
  2. 13
      Lib.Audio/Factories/IControllableCollectorFactory.cs
  3. 13
      Lib.Audio/Interfaces/IControllableCollector.cs

@ -0,0 +1,28 @@
// Author: Gockner, Simon
// Created: 2021-04-08
// Copyright(c) 2021 SimonG. All Rights Reserved.
using System.Collections.Generic;
using System.Linq;
using Lib.Audio.Factories;
using Lib.Audio.Interfaces;
using NAudio.CoreAudioApi;
namespace Lib.Audio
{
public class ControllableCollector : IControllableCollector
{
private readonly IControllableFactory _controllableFactory;
public ControllableCollector(IControllableFactory controllableFactory) => _controllableFactory = controllableFactory;
public List<IControllable> Controllables => CreateControllables();
private List<IControllable> CreateControllables()
{
MMDeviceEnumerator deviceEnumerator = new();
MMDeviceCollection? audioDevices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);
return audioDevices.Select(a => _controllableFactory.Create(a.AudioSessionManager.AudioSessionControl)).ToList();
}
}
}

@ -0,0 +1,13 @@
// Author: Gockner, Simon
// Created: 2021-04-08
// Copyright(c) 2021 SimonG. All Rights Reserved.
using Lib.Audio.Interfaces;
namespace Lib.Audio.Factories
{
public interface IControllableCollectorFactory
{
IControllableCollector Create();
}
}

@ -0,0 +1,13 @@
// Author: Gockner, Simon
// Created: 2021-04-08
// Copyright(c) 2021 SimonG. All Rights Reserved.
using System.Collections.Generic;
namespace Lib.Audio.Interfaces
{
public interface IControllableCollector
{
List<IControllable> Controllables { get; }
}
}
Loading…
Cancel
Save