Re: [LAD] Library for accurate time stamping using a DLL

From: Olivier Guilyardi <ml@email-addr-hidden>
Date: Tue Jan 27 2009 - 14:49:49 EET

Stefan Kost wrote:
> Olivier Guilyardi schrieb:
>>
>> [...]
>> However, although my measures are pretty encouraging, I am not 100% sure of my
>> DLL implementation. Could you please review it ? It's there:
>> http://svn.samalyse.com/pendule/trunk/src/pendule.c
>>
> instead of gettimeofday() you could use
> clock_gettime(CLOCK_MONOTONIC,..) where its available. Its a posix
> function and it has the benefit of beeing monotonic, where
> gettimeofday() is imho useless if you run ntp.

Thanks for this remark. I did not know clock_gettime(). However, the real
question may not be which clock source is the most reliable, but which one is
used as the master clock.

For example, in FFmpeg, each audio and video packets are tagged using a PTS
which is computed using av_gettime() which calls gettimeofday(). This is the
master timing source to synchronize the audio and video input streams which may
well be generated according to their own clocks.

This is why I thought about adding a new function to the API,
pendule_set_master_time_reader(double (* func) (void)) or similar, that would
allow to set which ever function you like to retrieve the master time. This
function should returned the current time as a double representing the number of
seconds since the Epoch.

> also in _new() you should probably use calloc, or make sure you init all
> fields.

pendule_cycle() must be called before pendule_gettime() or pendule_stats().
That's the way all fields get initialized. Otherwise the results are
undetermined. I suppose stating this in the (to be written) docs should be
sufficient. Initializing values in pendule_new() is irrelevant, since this can
only be done in real-time, which pendule_cycle() is for. For example, setting
current_time to zero (1/1/1970 at midnight) in pendule_new() isn't more relevant
than any other random value to me.

I'll try to add doc blocks to pendule.h soon.

>> You can grab everything using svn:
>> svn co http://svn.samalyse.com/pendule/trunk pendule
>>
>> I'd like to know how it works for others. You can easily test your
>> hardware/system and make graphs with:
>>
>> ./waf configure
>> ./waf build
>> ./measure
>> ./graph
>>
>> Check the README for more.

-- 
  Olivier
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Tue Jan 27 16:15:05 2009

This archive was generated by hypermail 2.1.8 : Tue Jan 27 2009 - 16:15:05 EET