About the scope of CSoundManager Object

Started by
-1 comments, last by Sobero 19 years ago
Hello every one, I am writing a program using direct sound. I have some questions on the scope of the CSoundManager Object. I create the object in one function and call its Create() method in another function just like below codes: void Initialize() { ................. if (SUCCEEDED(snd_manager->Initialize(g_phWnd,DSSCL_PRIORITY))) cout << "Initialize Sound Manager!\n"; ..................... ................... } void Play() {....................... if (SUCCEEDED(snd_manager->Create(&snd,TEXT("c:\\ding.wav"),0,GUID_NULL,1))) cout << "Sound loaded!\n"; if (SUCCEEDED(snd->Play(0,0))) cout << "Sound played!\n"; .................................... ............................. } The CSoundManager and CSound variables are declared as global. But I found that after exit the Initialize() function and call the Play() function, the CSoundManager object becomes NULL. Why does it occur even if the CSoundManager object is declared as global variables? Thank you!!

This topic is closed to new replies.

Advertisement