Skip to content

Commit 4c1a1b0

Browse files
committed
Add option to use SilentAudioPlayer for testing purposes
1 parent 2da0521 commit 4c1a1b0

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/Beep/AudioPlayer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public AudioPlayer(AudioFormat audioFormat, int sampleRate = 44100, int channelC
4040

4141
IAudioPlayer audioPlayer;
4242

43-
if (OperatingSystem.IsMacOS())
43+
if (playerOptions.UseSilentAudioPlayer)
44+
{
45+
audioPlayer = new SilentAudioPlayer();
46+
}
47+
else if (OperatingSystem.IsMacOS())
4448
{
4549
audioPlayer = new AudioQueuePlayer(sampleRate, channelCount, playerOptions);
4650
}

src/Beep/PlayerOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public sealed class PlayerOptions
3030
/// </summary>
3131
public bool ThrowOnUnsupportedPlatform { get; set; }
3232

33+
/// <summary>
34+
/// Gets or sets a value indicating whether to use the silent audio player. This is useful for testing purposes.
35+
/// </summary>
36+
public bool UseSilentAudioPlayer { get; set; }
37+
3338
internal void ThrowIfNotValid()
3439
{
3540
if (BufferSizeInBytes < 1)

0 commit comments

Comments
 (0)