Why would waveOutWrite() cause an exception in the debug heap?

前端 未结 9 1404
甜味超标
甜味超标 2021-02-05 16:51

While researching this issue, I found multiple mentions of the following scenario online, invariably as unanswered questions on programming forums. I hope that posting this here

9条回答
  •  我寻月下人不归
    2021-02-05 17:37

    What about the fact that you are not allowed to call winmm functions from within callback? MSDN does not mention such restrictions about window messages, but usage of window messages is similar to callback function. Possibly, internally it's implemented as a callback function from the driver and that callback does SendMessage. Internally, waveout has to maintain linked list of headers that were written using waveOutWrite; So, I guess that:

    hdr->reserved = (Undocumented*)calloc(sizeof(Undocumented));
    

    sets previous/next pointers of the linked list or something like this. If you write more buffers, then if you check the pointers and if any of them point to one another then my guess is most likely correct.

    Multiple sources on the web mention that you don't need to unprepare/prepare same headers repeatedly. If you comment out Prepare/unprepare header in the original example then it appears to work fine without any problems.

提交回复
热议问题