[Openal] AL_BUFFERS_PROCESSED Issue on Linux
Andrew Baker
andyb at binarybydesign.net
Wed Aug 25 04:37:15 PDT 2004
Quoting "P.J. Cast." <pjcast at yahoo.com>:
> >It would appear that underrun was the issue. The
> >playback is being started prior
> >to a level load which caused a brief underrun. I've
> >implemented underrun code
> >and it works fine.
>
> Hello all,
>
> I am having this same problem using Vorbis and my code
> is pretty much Identical to yours. I am really hoping
> you could show me the code you used to check for this
> buffer underrun/fix it because I am lost :(
>
No problem. The revised ticker function is as follows:
---> CODE SNIPPET START ,--
//
// oggplayer_c::Ticker()
//
void oggplayer_c::Ticker()
{
if (status == oggplayer_c::PLAYING)
{
int result;
int processed;
bool active = true;
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
while(processed--)
{
ALuint buffer;
alSourceUnqueueBuffers(source, 1, &buffer);
result = alGetError();
if(result != AL_NO_ERROR)
{
epi::error_c e
(ERR_MUSIC, "[oggplayer_c::Ticker] alSourceUnqueueBuffers() Failed");
throw e;
}
active = StreamIntoBuffer(buffer);
alSourceQueueBuffers(source, 1, &buffer);
result = alGetError();
if(result != AL_NO_ERROR)
{
epi::error_c e
(ERR_MUSIC, "[oggplayer_c::Ticker] alSourceQueueBuffers() Failed");
throw e;
}
}
// Check for underrun
if (active)
{
int state;
// We have data, so we should be playing...
alGetSourcei(source, AL_SOURCE_STATE, &state);
if (state != AL_PLAYING)
{
alGetSourcei(source, AL_BUFFERS_PROCESSED,
&processed);
alSourcePlay(source);
}
}
else
{
// No more data. Seek to beginning and stop if not
looping
ov_raw_seek(&ogg_stream, 0);
if (!looping)
Stop();
}
}
}
---> CODE SNIPPET END <---
Cheers
--
Andrew Baker
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
More information about the Openal
mailing list