Книга: DirectX 8 Programming Tutorial

Cleaning up

Cleaning up

In the CSound destructor we simply stop the sound from playing and release the objects. In CGame there is a new function called CleanUpDirectAudio which is shown below:

void CGame::CleanUpDirectAudio() {
 //Stop all sounds.
 m_pDirectAudioPerformance->Stop(NULL, NULL, 0, 0);
 //CleanUp
 m_pDirectAudioPerformance->CloseDown();
 SafeRelease(m_pDirectAudioLoader);
 SafeRelease(m_pDirectAudioPerformance);
 LogInfo("<li>CleanUpDirectAudio finished.");
}

Here we first stop all sounds from playing (just in case), then we close down the performance object before releasing it and the loader object. Also, in the CGame deconstructor we need to call CoUninitialize to close down the COM library (shown below).

CoUninitialize();

So now we can play music and sounds in our applications. When the application starts, the background mp3 file plays. Move the mouse and click on a number to hear a different "sound effect". The background mp3 track is just a short loop so that I could keep the download size low, you can replace this with a larger track if you wish.


Оглавление книги


Генерация: 7.018. Запросов К БД/Cache: 2 / 0
поделиться
Вверх Вниз