Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Issue: ComException when unplugged playback device [16329]

$
0
0
When playbackdevice disapears from windows playback devices (when user unplugs device from usb or audio jack port or disable it) while playling file, an COMException occrus in DirectSoundOut.StopPlayback() method on line 475: secondaryBuffer.Stop();

I don't know if it is possible to handle the exception from wpf application since it is in another thread.

I attached working sample project. just click the play button and unplug the device. if there's more than one playback device, then disable them. Exception occurs only when last device is disabled/uplugged.

You have a try..catch..finally bock in PlaybackThreadFunc, but when an exception is caught, then you call the com methods in finally block without try catch. You should at least use try..catch(ComException).


System.Runtime.InteropServices.COMException was unhandled
Message=Exception from HRESULT: 0x88780096
Source=NAudio
ErrorCode=-2005401450
StackTrace:
at NAudio.Wave.DirectSoundOut.IDirectSoundBuffer.Stop()
at NAudio.Wave.DirectSoundOut.StopPlayback() in C:\Users\Admin\Desktop\NAudio\naudio_db92aece4b2f\NAudio\Wave\WaveOutputs\DirectSoundOut.cs:line 475
at NAudio.Wave.DirectSoundOut.PlaybackThreadFunc() in C:\Users\Admin\Desktop\NAudio\naudio_db92aece4b2f\NAudio\Wave\WaveOutputs\DirectSoundOut.cs:line 442
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Comments: I have implemented some more changes to DirectSoundOut for better handling of a device gone missing (being unplugged). I have attached the latest revision to this comment. It is InSync with the latest sources as of 3f2bfe6abd55 (6 days ago). I have also applied the fix mentioned in the post above which did help. Mark, if you get a chance please Diff the changes and get this implemented, thanks!

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>