0
0

Hello there,

The tools:

I am using FMOD Ex 4.04.28 over Windows XP Proffesional in a game I am trying to develope.

The context:

I have written a Sound Manager class which has a FMOD::Sound *backgroundMusic attribute.

I use this pointer to load the backgroundMusic of each stage of the game. I use a switch sentence to determine which music should be loaded when a new stage is loaded.

The problem:

When I load the third stage (TowerFloor0), the backgroundMusic pointer is not updated and I get an FMOD_ERR_INVALID_HANDLE.
I have tried swapping the code of the switch cases and the problem always happen in the third stage (please, look for the "I get the error here" label to find the exact line where I get the error).

The code:

[code:3l5afk28] switch ( (int)sceneName ) {
case TitleScreen :
result = system->createStream("resource/media/MUSIC_TitleScreen.mp3",
FMOD_2D
0,
&backgroundMusic);
ERRCHECK(result);

        result = backgroundMusic->setMode(FMOD_LOOP_OFF);
        ERRCHECK(result);

        break;

    case LandOfSorrows :

        result = system->createStream(    "resource/media/MUSIC_Outdoors1.mp3",
                                        FMOD_2D,
                                        0,
                                        &backgroundMusic);
        ERRCHECK(result);

        result = backgroundMusic->setDefaults(44100.0f,0.5f,0.0,256);
        ERRCHECK(result);

        result = backgroundMusic->setMode(FMOD_LOOP_NORMAL);
        ERRCHECK(result);

        break;

    case TowerFloor0 :
        //********************
        //  I get the error  here  *
        //********************
        result = system->createSound("resource/media/MUSIC_soulcage_floor0.mp3",
                                        FMOD_2D,
                                        0,
                                        &backgroundMusic);
        ERRCHECK(result);

        result = backgroundMusic->setDefaults( 44100.0f,1.0f,0.0,256);
        ERRCHECK(result);

        result = backgroundMusic->setMode(FMOD_LOOP_NORMAL);
        ERRCHECK(result);

        break;
}

[/code:3l5afk28]

That’s it!

Shouldn’t this variable be simply overriden by the new sound as it is in the previous case?

Any help would be much appreciated! :)

Thanks a lot.

  • You must to post comments
0
0

I think I found the problem. It seems someone was calling the destructor of the class between the different scenes.

I hope it serves to help someone!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.