Jump to content

Releasing Sounds


Recommended Posts

Hi,

I noticed, when playing a sound via (C++):

Sound* s = Sound::Load("Sound\\Footsteps\\jump.wav");
s->Play();

the RefCount of the Sound will be increased but not decreased after the sound is done playing.

However, playing the sound via

Entity* e = world->entities.front();
e->EmitSound(s);

will increase the RefCount but also decrease it, after it is done playing.

 

This should be consistent, because this has consequences:

When using Play(), I can instantly after playing the sound release it with

s->Release();

When using EmitSound() and doing the same, after the sound is done playing, I get into the DebugErrorHook with the message "OpenAL: AL_INVALID_OPERATION" and the game stops. I guess, this happens, because the latter method releases the sound after finishing playing it and thus the RefCount gets decreased and reaches 0, so that the sound gets deleted which is somehow a problem for OpenAL.

Link to comment
Share on other sites

  • 1 month later...

Thanks. I am modifying the behavior. Sound::Play() will increment the sound refcount, then auto-collect it when done playing.

 

Proper usage:

Sound* sound = Sound::Load("blah.,wav");
sound->Play();
sound->Release();

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...