0
0

Hello,

I haver created a very simple sound, which plays a four second long .wav file. When I want to check if the Channel is still playing using FMOD_Channel_IsPlaying, I get an error (FMOD_ERR_INVALID_HANDLE) when the sound actually stopped. When I check this manually before the ending of the sound everything is fine?

I have checked the value of the channel pointer (mChannel in my case) passed to the method, and that seems to be OK.

Here is part of my code
[code:7ntphf26]
FMODSoundObject::FMODSoundObject(const Ogre::String& name, SoundResourcePtr& soundResource,
const Ogre::NameValuePairList* params)
: SoundObject(name, params),
mChannel(0)
{
mSoundResource = soundResource;

    // Store the channel handle for direct access to attributes
    mSystem = static_cast<FMODSoundSystem*>(SoundSystem::getSingletonPtr())->_getFMODSystem();
    FMOD_SOUND* sound = reinterpret_cast<FMOD_SOUND*>(soundResource->_getID());

    // Check if the sound still supports 3D spatialisation
    FMOD_MODE mode;
    FMOD_Sound_GetMode(sound, &mode);
    if (mode & FMOD_3D) 
    {
        mIs3D = true;
    }
    else
    {
        mIs3D = false;
    }

    _initialise();
};
void FMODSoundObject::stop(void)
{
    if (mChannel && isPlaying())
    {
        FMOD_RESULT result = FMOD_Channel_Stop(mChannel);
        OGRESOUND_FMOD_ERROR("FMODSoundObject::stop", result);
        mChannel = 0;
    }
};
const bool FMODSoundObject::isPlaying(void)
{
    if (!mChannel)
    {
        return false;
    }
    FMOD_BOOL playing;
    FMOD_RESULT result = FMOD_Channel_IsPlaying(mChannel, &playing);
    OGRESOUND_FMOD_ERROR("FMODSoundObject::isPlaying", result);
    // If playing, check if paused
    if (playing == 1)
    {
        // If not paused object is playing
        return !isPaused();
    }
    else
    {
        return false;
    }
};

[/code:7ntphf26]

The construction seems to be ok, since I can play the sound properly and can stop and check it when the sound is still playing.
The same issue occurs when I call FMOD_Channel_Stop, that is why I check whether the SoundObject isPlaying. To me it seems logical that I don;t have to do this check and I can stop a sound whether it is playing or not, but this doesn’t seem to be the case.

What can I do about this issue? If you need more code to help me out, please tell me.

  • You must to post comments
0
0

Well 😳 sometimes a little chat with friends might help as well…

What I didn’t have in mind was the virtual system of FMOD channels. So I forgot to check if the FMOD_RESULT in stop() or isPlaying() returns FMOD_ERR_INVALID_HANDLE.
I do a check now before I throw an exception: if (result != FMOD_ERR_INVALID_HANDLE && result != FMOD_OK)

Thank you!

  • You must to post comments
0
0

oh i see i didnt know your error check threw an exception, so thats why :)

  • You must to post comments
0
0

yups, OGRESOUND_FMOD_ERROR is a macro that defines an exception (is the right way of saying this?), so I can see rather easy in OGRE what’s going on when something goes wrong… quite helpful every now and then…

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.