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

Commented Unassigned: Deadlock in Callback with WaveOut.GetPosition [16398]

$
0
0
I call WaveOut.GetPosition up to 60 times per second to sync an animation, and when using the Callback strategy, I get deadlocks very quickly (within 20-30 seconds) and consistently (all the time). I've [described the problem in more detail](http://stackoverflow.com/a/16468906/1174169) on Stack Overflow.

I made a change in WaveOut.Callback to delegate the work to the thread pool. I'm not sure if this is the best idea, as I'm not so familiar with the source of NAudio. Do you think this is a good idea? I've checked in the changes on [my NAudio fork](https://naudio.codeplex.com/SourceControl/network/forks/cod3monk3y/NAudio/changeset/1b3747e016b6).

I had to update the profile to 4.0 in order to use the `Task` class.

This solves the deadlock issue, and pretty much runs exactly the same way. The only difference (besides non deadlock) is that the thread running the callback isn't an OS thread. It's a thread pool thread.

Thanks!
/cm
Comments: The person who contributed the position reporting only did it for WaveOut, not WaveOutEvent, but the same change could easily be made. It's something I should try to get in for NAudio 1.7. You can either make your own build, or make your own custom version of WaveOutEvent for now. I would stay away from function callbacks though. I tried for over 5 years to flush out all the possible deadlocks. It turns out to be very dependent on soundcard drivers. Some have no issues whatsoever, while other (Realtek is a major culprit) deadlock all over the place.

Viewing all articles
Browse latest Browse all 738

Trending Articles



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