-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced AudioContext, a class for wrapping all related device func…
…tionality into one place, will also provide a single point of extension. Created a SystemAudioContext class for the system devices. Resharper code cleanup!
- Loading branch information
1 parent
4019a0c
commit 25ef8ff
Showing
14 changed files
with
148 additions
and
26 deletions.
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,30 @@ | ||
namespace AudioSwitcher.AudioApi | ||
{ | ||
public abstract class AudioContext | ||
{ | ||
|
||
public AudioController Controller | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public PreferredDeviceManager PreferredDeviceManager | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
protected AudioContext(AudioController controller, PreferredDeviceManager preferredDeviceManager) | ||
{ | ||
Controller = controller; | ||
PreferredDeviceManager = preferredDeviceManager; | ||
|
||
if (Controller != null) | ||
Controller.Context = this; | ||
|
||
if (PreferredDeviceManager != null) | ||
PreferredDeviceManager.Context = this; | ||
} | ||
} | ||
} |
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
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
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
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,30 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace AudioSwitcher.AudioApi | ||
{ | ||
public interface IPreferredDeviceManager | ||
{ | ||
AudioContext Context { get; } | ||
|
||
IEnumerable<AudioDevice> PreferredDevices { get; } | ||
|
||
AudioDevice NextPlaybackDevice(); | ||
|
||
AudioDevice PreviousPlaybackDevice(); | ||
|
||
AudioDevice NextRecordingDevice(); | ||
|
||
AudioDevice PreviousRecordingDevice(); | ||
|
||
void AddDevice(AudioDevice ad, int position = 0); | ||
|
||
void RemoveDevice(AudioDevice ad); | ||
|
||
bool IsPreferredDevice(AudioDevice ad); | ||
|
||
void Save(Stream s); | ||
|
||
void Load(Stream s); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace AudioSwitcher.AudioApi | ||
{ | ||
/// <summary> | ||
/// Used to manage the preferred devices | ||
/// </summary> | ||
public abstract class PreferredDeviceManager : IPreferredDeviceManager | ||
{ | ||
protected PreferredDeviceManager(AudioController controller) | ||
{ | ||
Controller = controller; | ||
} | ||
|
||
public AudioController Controller { get; private set; } | ||
public AudioContext Context { get; internal set; } | ||
|
||
public abstract IEnumerable<AudioDevice> PreferredDevices { get; } | ||
|
||
public abstract AudioDevice NextPlaybackDevice(); | ||
|
||
public abstract AudioDevice PreviousPlaybackDevice(); | ||
|
||
public abstract AudioDevice NextRecordingDevice(); | ||
|
||
public abstract AudioDevice PreviousRecordingDevice(); | ||
|
||
public abstract void AddDevice(AudioDevice ad, int position = 0); | ||
|
||
public abstract void RemoveDevice(AudioDevice ad); | ||
|
||
public abstract bool IsPreferredDevice(AudioDevice ad); | ||
|
||
public abstract void Save(Stream s); | ||
|
||
public abstract void Load(Stream s); | ||
} | ||
} |
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 @@ | ||
namespace AudioSwitcher.AudioApi.System | ||
{ | ||
public class SystemAudioContext : AudioContext | ||
{ | ||
public SystemAudioContext() | ||
: this(null) | ||
{ | ||
} | ||
|
||
public SystemAudioContext(PreferredDeviceManager preferredDeviceManager) | ||
: base(new SystemAudioController(), preferredDeviceManager) | ||
{ | ||
} | ||
} | ||
} |
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