Platform SDK: DirectX

Step 8: Stop Capture

[Visual Basic]

The information in this topic pertains only to applications written in C and C++. See DirectSound Visual Basic Tutorials.

[C++]

When it's time to stop recording, call the following function:

BOOL StopWrite()
{
    IDirectSoundCaptureBuffer_Stop(lpdscb);
    StreamToFile();  
    WaveCloseWriteFile(&hmmio, &mmckinfoData, 
            &mmckinfoParent, &mmioinfo, 
            dwTotalBytesWritten / (wfx.wBitsPerSample / 8));
    return TRUE;
}
 

This function stops the capture buffer, calls the StreamToFile function one more time in order to save all the data up to the current read position, and closes the file. The WaveCloseWriteFile function in Wavwrite.cpp also updates the header of the data chunk by writing the total number of samples.

Next: Step 9: Shut Down DirectSoundCapture