[vorbis-dev] ogg123 timekeeping

Bob Miller kbob at jogger-egg.com
Wed Aug 2 10:36:37 PDT 2000



Kenneth Arnold wrote:

> Does this look okay? :

Almost.  Consider this case, though.

        start_time = 00:00:59.6	(tv_sec = 59, tv_usec = 600000)
        cur_time   = 00:01:59.5	(tv_sec = 119, tv_usec = 500000)

The code posted calculates c_min = 1, c_sec = -0.9;

Here's a fix (I think), assuming that c_min and c_sec are integral types.

<       c_min = (long) (cur_time.tv_sec - start_time.tv_sec) / (long) 60;
<       c_sec = (cur_time.tv_sec - start_time.tv_sec) - 60 * c_min +
<         ((cur_time.tv_usec - start_time.tv_usec) / 1000000.0);

---
>       c_sec = (cur_time.tv_sec - start_time.tv_sec) +
>         ((cur_time.tv_usec - start_time.tv_usec) / 1000000.0);
>	c_min = c_sec / 60;
>	c_sec -= 60 * c_min;

> Scream now! I'm committing...

Sorry, I wasn't looking.  I promise not to let it happen again... (-:

-- 
                                        K<bob>
kbob at jogger-egg.com, http://www.jogger-egg.com/

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/




More information about the Vorbis-dev mailing list