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

Commented Issue: WasapiCapture class - deadlock in StopRecording() [16128]

$
0
0
Deadlock has place in StopRecording() in WasapiCapture class in the implementation presented in WavRecording demo code.
When Stop button is pressed then StopRecording() is launched. Flag stop is set to true.
StopRecording calls waits for thread "captureThread.Join();".
When recording thread detects stop flag, then it calls Dispose().
Dispose() calls again StopRecording(), but we already were here and we are waiting for thread. So thread.Join is called for the second time, and we have deadlock problem.
I avoided this problem with extending condition in StopRecording():
if (this.captureThread != null && this.stop == false)
instead of
if (this.captureThread != null)

Regards.
Piotr.
Comments: I think I'll fix this another way. StopRecording() should not do a join, it should just signal for recording to stop. We have the RecordingStopped event that users can wait on if they need to know it has finished

Viewing all articles
Browse latest Browse all 738

Trending Articles



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