PDA

View Full Version : OpenAL can't replay sounds


Zeussy
02-13-2006, 08:41 PM
So, I've been busy, modifiy the tutorials around to make a OpenAL wrapper class.

I've been writing a renderer in Directx and linking objects to sources so I can update there position and stuff, but that isnt so much the problem.

I can't replay a sound once its been played, here is my little function:


void zSoundEngine::PlaySound( int Source )
{
//Check if sound is playing
int play;
alGetSourcei(g_Sources[Source], AL_SOURCE_STATE, &play);

if (play != AL_PLAYING)
{
// Play
alSourcePlay(g_Sources[Source]);
if ((error = alGetError()) != AL_NO_ERROR)
DisplayALError("alSourcePlay : ", error);

}
}


Now, it plays the sound once, then never again. But if I step through, it will repeat the sound. But only if I step through alSourcePlay.

Another thing I have noticed, i downloaded the Multiple sources Tut, and just ran the ExE, none of the sources replay in that, appart from the looping battlefield sound.

So I'm completely stumped, almost seems like a dodgy dll to me, but idk.

Any help will be appreciated.

lazarus
07-26-2006, 06:36 AM
Call alSourceRewind(g_Sources[Source]) before alSourcePlay(...)

monjardin
07-26-2006, 07:53 AM
Lazarus (http://en.wikipedia.org/wiki/Lazarus#The_miracle_of_Lazarus): What an appropriate name for a forum necromancer!