low-level audio callback function crash
Posted on 1997-07-02
I'm using Visual C++ 5.0 to write a simple console application that makes use of the low-level audio routines to continuously record waveform audio for analysis, and have run into a problem.
The audio object that I've written does the following:
1) fills a WAVEFORMATEX structure with the appropriate values.
2) calls waveInOpen with the structure, specifying a waveInProc callback function.
3) GlobalAllocs storage for two WAVEHDR structures and two 4K audio interrupt buffers and sets the data and size fields appropriately.
4) calls waveInPrepare and waveInAdd for the WAVEHDR structs.
5) calls waveInStart to start recording.
The problem is that after step 2) and before waveInStart is called, the program crashes with an
"Unhandled exception in Audio.exe : 0xc0000005: Access violation".
The stack is way overflowed, registers are trashed and register EBP contains the HWAVEIN handle that was used in waveInOpen.
I suspect that its crashing in the waveInProc callback function, but this happens even if the function does absolutely nothing!