[pulseaudio-discuss] precise stream timing

Colin Guthrie gmane at colin.guthr.ie
Thu Jun 2 07:51:39 PDT 2011


'Twas brillig, and Matt Robbins at 02/06/11 16:33 did gyre and gimble:
> Hello Pulseaudio community,
> 
> I'm playing around with pulse to assess suitability for my project, and
> while it seems like I should be able to do what I want, I'm struggling
> with the API.  Essentially, I need to record audio data with precise
> (~1ms) time stamps.  I'm doing collaborative sound source localization
> between several machines, all synced to gps time.  Since I don't really
> need sample-accurate time, I figured it would be acceptable to call
> gettimeofday() on ALSA interrupts to get a pretty good idea of when the
> samples were recorded.  Since all of the machines will be using the same
> hardware, I don't even care if there's some fixed latency involved.
>  While doing this in ALSA would be an interesting project, when combined
> with some the other things I need to do (stream splitting, fixed-point
> resampling, etc.), it feels like I'd be reinventing the wheel.  I've
> been using JACK to accomplish what I need, but there are stability and
> support issues on the embedded systems I'm using, so I'm looking into
> alternatives, especially since the recent headless ubuntu release, which
> has a working pulse server by default :)
> 
> I've tried cobbling something together using the pacat.c source using
> pa_stream_set_read_callback().  My callback gets called, but although I
> call pa_stream_get_timing_info(), I can't see how to derive the
> information I need from the pa_timing_info struct because I can't see
> how the timestamp field is related to the current fragment.  
> 
> I'm not even sure if I'm going about this the right way, so if anyone
> who knows the system could give me a few pointers, I'd really appreciate it.

I suspect you want to use:
pa_stream_get_time().

This returns the usecs since the stream started... this is likely what
you want (IIUC).

Cheers

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



More information about the pulseaudio-discuss mailing list