This project has moved. For the latest updates, please go here.

DirectSoundOut seems to be wrong

Apr 11 at 8:31 AM
Edited Apr 11 at 9:24 AM
DirectSoundOut::GetPosition() seems to be useless.

Because you need to have access from the same thread you have created on.
Otherwise an E_NO_INTERFACE exception occured. You create a private thread here - so no chance to use it.

Not easy to fix this, but to fire an event at the beginning and/or end of your while loop in the seperate thread would be helpful. (Give me the chance to cache it)

EDIT: An option for the thread priority should be helpful because i have problems when some system steps interupts the audio player a bit(thats why i use direct sound - just click on context desktop menu/refresh cause a hang in Naudio::waveout device)

*Sebastian
Apr 12 at 2:43 PM
I fix it by modifing the NAudio sourcecode in DirectSoundOut.cs
  • do check for IWaveProvider.Init has been called before thread want create
  • give easy access to IDirectSoundBuffer properties from another thread
  • spend some diagnostic properties and playback event from origin thread
  • make sure thread will be destroyed if ThreadProc cause an exception
Do you care for pull requests?

*Sebastian
May 11 at 8:18 PM
Mark includes pull requests on github, codeplex remains just for discussions.