Platform SDK: DirectX

Step 7: Shut Down DirectSound

[Visual Basic]

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

[C++]

Before closing, your application needs to close any open wave file and release the DirectSoundNotify and DirectSound objects. Note that because you queried for the IDirectSoundNotify interface from a DirectSoundBuffer object, you must release the DirectSoundNotify object before releasing DirectSound. Releasing DirectSound automatically releases any existing buffers.

The following function does all the necessary cleanup:

void DSExit(void)
{
    Close();
    if (lpdsNotify)
        lpdsNotify->Release();
    if (lpds)
        lpds->Release(); 
}