[Openal]How to calculate the true 'current-playing-time' for a streaming source?

Ed icelus2k5 at gmail.com
Mon Mar 3 04:02:52 PST 2008


On 03/03/2008, Keshav B Channa <kbc at dhruva.com> wrote:
> Hi,
>
>  Which is the best method to calculate the 'current-playing-time' for a streaming source, in real-time?
>
>  Right now, I'm doing this: (this is not real time determination)
>  After every buffer is finished processing, I calculate the 'duration' of that buffer, and add it to a variable.
>  There is a lag of the current buffer that is already being processed.
>

>  Is there a function to determine the "total bytes processed" for a source, so that I can determine the current-time accurately and precisely?
>
>  Or if you know of any other method, then please let me know.
>
>  I need high accuracy for determining the current playing position.
>
>
>
>  Also, the time returned by AL_SEC_OFFSET seems to be different from the timer that I'm using.
>  Has anybody else had this problem?

AL_BYTE_OFFSET tells you the amount of bytes from the start of the
queue that have been processed. AL_SEC_OFFSET tells you the seconds
from the start of the queue that have been played. If you're
streaming, you're pulling buffers off the start of the queue and
pushing them to the end regularly. The easiest method I know is every
time you pull a buffer off the queue, add its play time to your stored
"time played before queue start" variable. (which obviously starts at
zero when you start the stream). Then add AL_SEC_OFFSET to get:

 total time played before queue start + total time played in queue = total time

I haven't actually tried this (I'm still working on my stream api!);
let me know if this helps and/or works (!)


Ed


More information about the Openal mailing list