From alsa-devel-owner@alsa.jcu.cz  Thu Jun 25 15:12:51 1998
Received: from entry.jcu.cz (perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.8.8/8.8.8) with SMTP id PAA00578;
	Thu, 25 Jun 1998 15:11:38 +0200
Date: Thu, 25 Jun 1998 15:11:38 +0200 (MET DST)
From: Jaroslav Kysela <perex@jcu.cz>
To: Frank van de Pol <F.K.W.van.de.Pol@inter.nl.net>
cc: alsa <alsa-devel@jcu.cz>
Subject: Re: Time resolution needed for sequencer
In-Reply-To: <199806241944.VAA25193@obelix.fvdpol.inter.nl.net>
Message-ID: <Pine.LNX.3.96.980625145531.16213I-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

On Wed, 24 Jun 1998, Frank van de Pol wrote:

> +-----------------+------+-------------------------+
> | Data type       | Unit | Range                   |
> +=================+======+=========================+
> | 32 bit unsigned | ms   | 49.7 days               | <== My Favorite [tm]
> |                 | us   | 1.2 hours   (too short) | 
> |                 | ns   | 4.2 seconds (too short) |
> +-----------------+------+-------------------------+
> | 48 bit unsigned | ms   | 8925 years              |
> |                 | us   | 8.9 years               |
> |                 | ns   | 3.2 days    (short?)    |
> +-----------------+------+-------------------------+
> | 64 bit unsigned | ms   | 584E6 years             |
> |                 | us   | 584E3 years             |
> |                 | ns   | 584 years               |
> +-----------------+------+-------------------------+
> 
> 
> Questions:
> 
> 1) What unit for specifying a real-time timestamp is needed? And why?

I think that best should be something between ms and us for good
precision.

> 2) What data types are practical? Remember that choosing for 'difficult'
>    datatype very much affect application code because the application has
>    most to to with these timestamps.

What about this 48-bit format:

unsigned 32-bit - seconds
unsigned 16-bit - 0-49999 fraction (5 digits) after floating point divided
                          by two

I assume that code which will work with timestamps needs only compare two
timestamps and addition.

This format is very similar (and thus should be easy converted by only
one multiplication) to:

struct timeval {
        int     tv_sec;         /* seconds */
        int     tv_usec;        /* microseconds */
};

Current system time is returned in above structure.

						Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


