From 96880ae75783229ff4bcabd72368dbdb5ac6bdb2 Mon Sep 17 00:00:00 2001 From: Anna Date: Sat, 20 Nov 2021 23:13:12 -0500 Subject: [PATCH] fix: catch exceptions when playing sound --- Peeping Tom/TargetWatcher.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Peeping Tom/TargetWatcher.cs b/Peeping Tom/TargetWatcher.cs index 1b44422..3fe22e8 100644 --- a/Peeping Tom/TargetWatcher.cs +++ b/Peeping Tom/TargetWatcher.cs @@ -188,11 +188,15 @@ namespace PeepingTom { using var output = new WaveOutEvent { DeviceNumber = soundDevice, }; - output.Init(channel); - output.Play(); + try { + output.Init(channel); + output.Play(); - while (output.PlaybackState == PlaybackState.Playing) { - Thread.Sleep(500); + while (output.PlaybackState == PlaybackState.Playing) { + Thread.Sleep(500); + } + } catch (Exception ex) { + PluginLog.LogError(ex, "Exception playing sound"); } } }).Start();