22using System . Collections . Concurrent ;
33using System . Collections . Generic ;
44using System . Linq ;
5- using System . Runtime . CompilerServices ;
65using System . Threading ;
76using System . Threading . Tasks ;
87using NAudio . CoreAudioApi ;
@@ -36,6 +35,10 @@ public sealed class AudioDeviceProxy : IDisposable, IMMNotificationClient
3635 {
3736 return ;
3837 }
38+ catch ( Exception e )
39+ {
40+ Global . logger . Error ( e , "Unexpected error in NAudio thread" ) ;
41+ }
3942 }
4043 } )
4144 {
@@ -306,7 +309,6 @@ private void DisposeCurrentDeviceOnThread()
306309 DeviceChanged ? . Invoke ( this , EventArgs . Empty ) ;
307310 }
308311
309- [ MethodImpl ( MethodImplOptions . Synchronized ) ]
310312 public void OnDeviceStateChanged ( string deviceId , DeviceState newState )
311313 {
312314 if ( DeviceId != deviceId )
@@ -339,15 +341,13 @@ public void OnDeviceStateChanged(string deviceId, DeviceState newState)
339341 }
340342 }
341343
342- [ MethodImpl ( MethodImplOptions . Synchronized ) ]
343344 public void OnDeviceAdded ( string pwstrDeviceId )
344345 {
345346 if ( pwstrDeviceId != DeviceId ) return ;
346347 var mmDevice = _deviceEnumerator . GetDevice ( pwstrDeviceId ) ;
347348 SetDevice ( mmDevice ) ;
348349 }
349350
350- [ MethodImpl ( MethodImplOptions . Synchronized ) ]
351351 public void OnDeviceRemoved ( string deviceId )
352352 {
353353 if ( Device ? . ID == deviceId && Device ? . State != DeviceState . Active )
@@ -359,7 +359,6 @@ public void OnDeviceRemoved(string deviceId)
359359 /// <summary>
360360 /// Update the device when changed by the system.
361361 /// </summary>
362- [ MethodImpl ( MethodImplOptions . Synchronized ) ]
363362 public void OnDefaultDeviceChanged ( DataFlow flow , Role role , string ? defaultDeviceId )
364363 {
365364 if ( Flow != flow || ! AudioDevices . DefaultDeviceId . Equals ( DeviceId ) ) return ;
0 commit comments