[Openal] Get Audio time or buffer position
Casey Borders
thebeast.13 at gmail.com
Sat Nov 24 17:11:50 PST 2007
That's perfect!! Thanks!!
On Nov 24, 2007 7:20 PM, Chris Robinson <chris.kcat at gmail.com> wrote:
> On Saturday 24 November 2007 03:46:43 pm Casey Borders wrote:
> > I want to be able to "save" the current position in an audio stream so I
> > can come back and start that source right where it left off. I want to
> be
> > able to do this because I am working on some code to manage hardware
> > sources and I'll need to steal sources and shift them around from time
> to
> > time, so when I start a sound back up I'll need to know where to start
> it
> > up at. Does anyone have any suggestions?
>
> You can use the AL_SAMPLE_OFFSET (or AL_BYTE_OFFSET or AL_SEC_OFFSET(*))
> source attribute. eg:
>
> ALint stop_source(ALint source)
> {
> ALint pos;
> // Pause the source to prevent the offset from incrementing between
> // getting it and stopping the source (alSourceStop rewinds the source
> // back to 0)
> alSourcePause(source);
> alGetSourcei(source, AL_SAMPLE_OFFSET, &pos);
> alSourceStop(source);
>
> return pos;
> }
>
> void restore_source(ALint source, ALint pos)
> {
> alSourcei(source, AL_SAMPLE_OFFSET, pos);
> alSourcePlay(source);
> }
>
> (*) Using AL_BYTE_OFFSET may behave a little quirky with compressed
> formats,
> but should be fine otherwise. AL_SEC_OFFSET uses a float (ALfloat,
> alGetSourcef, alSourcef).
> _______________________________________________
> Openal mailing list
> Openal at opensource.creative.com
> http://opensource.creative.com/mailman/listinfo/openal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20071124/6a838105/attachment.html
More information about the Openal
mailing list