what is the correct way to play sound?

samme

13-08-2012 06:01:54

Actually I have followed some examples to create the sound and play, it seems very straight forward:

OgreOggSound::OgreOggISound* sound;
if ( sound = OgreOggSound::OgreOggSoundManager::getSingleton().createSound(name, filename, false/*streamed*/, loop))
{
sound->disable3D(true);
if (!loop)
sound->markTemporary();
sound->play();

However, after a certain number of sounds played (actually it is the max. number of sound defined in init()), non-positional sound will never be heard!
It is due to no sound created has "stopped" manually. After all sound sources has been used up, it will search for stopped sound to reuse. Since I have never call ->stop(), non of sound can be reused! Priority check will also fail, until playing positional sound will work in the last "distance" check.

What will be the correct way to play? Should I missed something to let the oggsound to stop automatically?

Or it is a bug to check mPlay in "isStopped" function call? (state is AL_STOPPED but mPlay is TRUE)

/*/////////////////////////////////////////////////////////////////*/
bool OgreOggISound::isStopped() const
{
if(mSource != AL_NONE)
{
ALenum state;
alGetError();
alGetSourcei(mSource, AL_SOURCE_STATE, &state);
return (!mPlay && (state != AL_PLAYING));
}

return false;
}

stickymango

27-08-2012 21:44:05

Hi samme,

This could well be a bug, I think I recently came across a similar scenario and changed the way this check is handled, I'll try to find the code and maybe upload a commit or perhaps post a code change which you can maybe confirm as a fix.

stickymango

30-08-2012 17:23:18

Committed a fix to SVN, see if it sorts out the issue...

Thanks.