From 484c7a98a8317589ca5a25efcb6403134f5f46e5 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 26 Oct 2018 10:35:12 -0500 Subject: [PATCH] Sound crash fixed in both INotifier and SoundAnimationView (the preview sound) --- src/client/spark/Notifications/INotifier.cs | 4 +++- .../DIYGrid/Settings/Animation/SoundAnimationView.xaml.cs | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Notifications/INotifier.cs b/src/client/spark/Notifications/INotifier.cs index 5934e1cfb..37f1f25ab 100644 --- a/src/client/spark/Notifications/INotifier.cs +++ b/src/client/spark/Notifications/INotifier.cs @@ -102,7 +102,9 @@ namespace mbts.ui { (_dispatcher = Dispatcher.CurrentDispatcher).UnhandledException += _on_dispatcher_UnhandledException; Dispatcher.Run(); } - } catch (Exception ex) { + } + catch (NAudio.MmException) { } + catch (Exception ex) { Log.assert(false, $"Exception in {Thread.CurrentThread.Name} thread: {ex}"); _disposer.Dispose(); } diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/SoundAnimationView.xaml.cs b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/SoundAnimationView.xaml.cs index 2e576c928..ff41bae64 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/SoundAnimationView.xaml.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/SoundAnimationView.xaml.cs @@ -28,7 +28,7 @@ namespace mbts.ui.controls { new AnonymousValueConverter(obj => obj is SoundNotification.SystemSound s ? EnumHelper.get_attribute(s)?.link : null); - + public static readonly DependencyProperty BusProperty = WPFHelper.create_dp(nameof(Bus)); @@ -38,7 +38,11 @@ namespace mbts.ui.controls { } public static ICommand PreviewSoundCommand => - new DelegateCommand(s => NAudioPlayer.create(s).play()); + new DelegateCommand(s => { + try { + NAudioPlayer.create(s).play(); + } catch (NAudio.MmException) { } + }); #region SoundTypes public static readonly DependencyProperty SoundTypesProperty =