Sign in to follow this  
Sobero

About the scope of CSoundManager Object

Recommended Posts

Sobero    122
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!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this