0
0

I sifted through quite a few topics, but this topic might have slipped by me. Here, I’ll show you the problem:

[code:i4yb3k2e]class Audio{

public:
....
....
Audio();
~Audio();

private:
FMOD::System *system;
};

void Initialize_FMOD(FMOD::System system);
void Load_and_Play(FMOD::System *system, const char
file_path);

void Initialize_FMOD(FMOD::System *system)
{
//Okay, so I pass in the pointer from the class. In Visual Studio
//it says its address is 0xcdcdcdcd, and rightfully so, since it hasn’t
//been initialized. It’s just a pointer, afterall.
//So I go through the process of calling System_Create(&system)
//and calling system->init. That’s all this function does.
}

void Load_and_Play(FMOD::System system, const char file_path)
{
//When it gets to my first FMOD function call in this method, which
//happens to be system->createStream(file_path, etc., etc.), it returns
//an Invalid Handle, which makes sense, because after returning out
//of my previous function, system is still a 0xcdcdcdcd pointer.
}[/code:i4yb3k2e]

So I need to find a way around this. I’m not allowed to have FMOD::System core_system, and then have *system = &core_system, and then pass *system to my functions because the FMOD::System constructor is private. I’m 99% sure that this has been covered somewhere on this site, so simple links to point me to the right post would be very helpful.

  • You must to post comments
0
0

All right, I figured it out. My functions need to be passed the pointers by reference. So, instead of having Initialize(FMOD::System *system), it should be Initialize(FMOD::System *&system). That way, the pointer outside of the scope of the function gets changed. Silly mistake.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.