Problem with waveOutWrite and waveOutGetPosition deadlock

后端 未结 3 1779
囚心锁ツ
囚心锁ツ 2021-01-22 15:05

I\'m working on an app that plays audio continuously using the waveOut... API from winmm.dll. The app uses \"leapfrog\" buffers, which are basically a

3条回答
  •  情歌与酒
    2021-01-22 15:32

    The solution to this was very simple (thanks to Larry Osterman): replace the callback with a WndProc.

    The waveOutOpen method can take either a delegate (for callback) or a window handle. I was using the delegate approach, which is apparently inherently prone to deadlocking (makes sense, especially in managed code). I was able to simply have my player class inherit from Control and override the WndProc method, and do the same stuff in this method that I was doing in the callback. Now I can call waveOutGetPosition forever and it never locks up.

提交回复
热议问题