Imagine this function:
void SoundManager::playSource(ALuint sourceID, float offset)
{
alSourceStop(sourceID);
ALint iTotal = 0;
ALint iCurrent = 0;
ALint uiBuffer = 0;
alGetSourcei(sourceID, AL_BUFFER, &uiBuffer);
alGetBufferi(uiBuffer, AL_SIZE, &iTotal);
iCurrent = iTotal * offset;
alSourcei(sourceID, AL_BYTE_OFFSET, iCurrent);
alSourcePlay(sourceID);
}
The idea is calling playSource(x, 0.5f) would jump to (roughly) halfway through the buffer, etc.
It works fine the first time I call it, but if I call it again on the same source (whether that source is playing or not) it begins playing as though I'd called it with offset 0.
Any ideas why?
From stackoverflow
frezned
-
I think you will have a better chance of getting an answer at irc.freenode.net ##openal
From digitalSurgeon -
Solved!
Even though the API claims that setting the offsets works on sources in any state, the problem was I should have been calling
alSourceRewindinstead ofalSourceStopat the start.It seems setting offsets only works on sources in the
AL_INITIALstate.From frezned
0 comments:
Post a Comment