Jump to content
  • Advertisement
Sign in to follow this  
Cornstalks

FMOD Freezes

This topic is 3768 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

I'm nearing the completion of my game, but I have one bug that's really holding me back. I'm using FMOD for sound and I'm programming in C++, but I have to use the FMOD's C API since the C++ API isn't supported by MinGW. Anyway, when I run my program, it freezes occasionally at startup. It took me awhile to track the bug, but now I've found where it's originating. I first create the sound system, and then I initialize it. However, sometimes (not always, in fact not usually) my program will freeze when I initialize the system. Below is the code I'm using (though I've cut everything unrelated out). In my log file, it says "Creating Sound Manager", and then "Sound system successfully created", but then nothing else, indicating that the program freezes during the FMOD_System_Init() function call. Am I doing something wrong in my code?
/* SoundManager.hpp */
class SoundManager
{
    public:
        SoundManager();
 
    protected:
        FMOD_SYSTEM* system;
        FMOD_SOUND* musicSound;
        FMOD_CHANNEL* music;
};

/* SoundManager.cpp*/
SoundManager::SoundManager() :
    system(NULL),
    musicSound(NULL),
    music(NULL)
{
    engine::EngineLog << "Creating Sound Manager\n";
 
    FMOD_RESULT result;
 
    result = FMOD_System_Create(&system);
    if (result != FMOD_OK)
    {
        engine::EngineLog << "Error creating the sound system\n";
    }
    else
    {
        engine::EngineLog << "Sound system successfully created\n";
    }
 
    ///////////////////// it freezes here ///////////////////////////////////////////////////
    result = FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, NULL);
    if (result != FMOD_OK)
    {
        engine::EngineLog << "Error initializing the sound system\n";
    }
    else
    {
        engine::EngineLog << "Sound system successfully initiated\n";
    }
 
    result = FMOD_System_CreateStream(system, "Lumme-BadLoop.ogg", FMOD_LOOP_NORMAL | FMOD_2D | FMOD_HARDWARE, NULL, &musicSound);
    if (result != FMOD_OK)
    {
        engine::EngineLog << "Error creating the music stream\n";
    }
    else
    {
        engine::EngineLog << "Stream successfully created\n";
    }
 
    result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musicSound, false, &music);
    if (result != FMOD_OK)
    {
        engine::EngineLog << "Error playing the music\n";
    }
    else
    {
        engine::EngineLog << "Music successfully played\n";
    }
 
    engine::EngineLog << "Sound Manager Created\n";
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!