Sign in to follow this  

About the scope of CSoundManager object in Direct Sound

This topic is 4675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Cross posting is evil.

At any rate, you have a lot of "......." in your source. It may be that something in there is causing your problem. It may also be something you are doing between the call to Initialize and the call to Play.

I would suggest that you set a breakpoint in the Initialize function and then single-step through the code. If your pointer goes from valid to NULL, you should be able to see when it happens.

Share this post


Link to post
Share on other sites

This topic is 4675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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