0
0

Second Edit: Seems the channel index stuff isn’t meant to do that, at least according to the docs. :/

Edit: The below quote was my original post, but we took our audio manager out into a console app and none of the errors show anymore. Which leads me to another question, is using the Integer Channel ID stuff much slower than using FMOD::Channel * directly?

[quote:259bhcjp]
I’m playing [b:259bhcjp]one[/b:259bhcjp] sound in a channel. After it has been started, I do channel->set3DAttributes () each tick.

I understand that after a sound has been stopped, finished or stolen – you’ll get an invalid handle error. That’s fine, but this sound is still audible and playing when I’m getting this error. I’m not playing any other sounds whatsoever so it hasn’t been stolen.

I’m doing system->update () and system->updateListener () every tick.

How I’m playing it:
[code:259bhcjp]
system->playSound (FMOD_CHANNEL_FREE, mBuffer, false, &mChannel);
[/code:259bhcjp]

Modes are:
[code:259bhcjp]
FMOD_CREATESAMPLE, FMOD_LOWMEM, FMOD_SOFTWARE, FMOD_3D, FMOD_3D_LOGROLLOFF, FMOD_LOOP_OFF
[/code:259bhcjp]

This is how my channel is defined in my class:
[code:259bhcjp]
public:
FMOD::Channel *mChannel;
[/code:259bhcjp]

This is the error:
[code:259bhcjp]
(35) An invalid object handle was used.
[/code:259bhcjp]

Does this look correct?
[/quote:259bhcjp]

  • You must to post comments
0
0

You shouldnt be using ‘integers’ for handles, you have to use what is returned from playsound. Either your sound has stopped or you are not passing in the handled returned from playsound to the other commands.

  • You must to post comments
0
0

Okay we solved it. If someone from FMOD could comment on this, I don’t know, perhaps put it in the documentation since it wasn’t mentioned there.

This is our play3D wrapper function:
[code:2jwbp5fh]
AudioManager::play3D (FMOD::Channel *channel, buffer, Transform, Velocity)
{
system->playSound (FMOD_CHANNEL_FREE, buffer, false, &channel);
}
[/code:2jwbp5fh]

It seems, for the programmatically challenged, that you can’t point channels in this manner. Am I correct in believing there’s some initialization going on in FMOD which effectivelly makes the pointer in the function definition above point to a different channel in the channel list, and not to the channel passed to the function call?

We wrapped each FMOD::Channel into a struct, and pointed the struct instead.. and now it’s working perfectly. Like this:

[code:2jwbp5fh]
struct SoundChannel
{
FMOD::Channel *channel;
};

AudioManager::play3D (SoundChannel *soundChannel, buffer, Transform, Velocity)
{
system->playSound (FMOD_CHANNEL_FREE, buffer, false, &soundChannel->channel);
}
[/code:2jwbp5fh]

Is this really obvious? Do I need to use double pointers for this stuff to work without the ugly hack above?

  • You must to post comments
0
0

[quote="Stefan Lundmark":ouodojju]It seems, for the programmatically challenged, that you can’t point channels in this manner. Am I correct in believing there’s some initialization going on in FMOD which effectivelly makes the pointer in the function definition above point to a different channel in the channel list, and not to the channel passed to the function call?[/quote:ouodojju]
It’s not FMOD, it’s C++ :)

When your function is called, the value of the pointer you pass in is copied into a new local FMOD::Channel* variable called "channel". You were giving FMOD the address of this local variable, and FMOD was changing the value of that variable inside playSound(). Once the function returns the local variable goes out of scope and is destroyed. Hello FMOD::Channel and memory leak :)

If you want to put it back the way it was without having to toss around structs, you can just give FMOD the double pointer.

[code:ouodojju]AudioManager::play3D (FMOD::Channel** channelptr, buffer, Transform, Velocity)
{
system->playSound (FMOD_CHANNEL_FREE, buffer, false, channelptr);
}
[/code:ouodojju]
…and the call to play3D:

[code:ouodojju]FMOD::Channel* myChannelPtr; // probably a member of a class
Manager->play3D( &myChannelPtr, <buffer>, <transform>, <velocity>);[/code:ouodojju]

  • You must to post comments
0
0

[quote="Dogbert":1qccfzlg]
It’s not FMOD, it’s C++ :)

When your function is called, the value of the pointer you pass in is copied into a new local FMOD::Channel* variable called "channel". You were giving FMOD the address of this local variable, and FMOD was changing the value of that variable inside playSound(). Once the function returns the local variable goes out of scope and is destroyed. Hello FMOD::Channel and memory leak :)[/quote:1qccfzlg]

Doh. I’m embarassed. I treated FMOD::Channel * as a non-pointer, thinking that.. uh, no – I didn’t think at all. Thanks alot!

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.