Thanks for your input Colin,  I think you understand correctly, but it doesn&#39;t look like pa_stream_get_time() is really going to do it for me.  I did find a way to get something close to what I want, however.  If it turn on PA_STREAM_AUTO_TIMING_UPDATE without PA_STREAM_INTERPOLATE_TIMING, then the time stamp returned by pa_stream_get_time() (or equivalently pa_stream_get_timing_info()) increases in a step-wise fashion.  This is fine, because I can estimate the time for the in-between step callbacks using the number of bytes read, and pa_bytes_to_usec().  <div>
<br></div><div>In fact, it seems like this estimate is quite precise.  Looking at the value of gettimeofday() on two separate clients when when the time stamp steps forward, they are nearly equal (within 500 usec), and I verified that the data recorded for that invocation of the callback is equal for both clients.   This looks really promising to me, but with more than two clients, the time difference starts to add up, and I wind up with unacceptably differing time estimates. <div>
<br></div><div>It seems like I ought to be able to use pa_timing_info to refine my estimate, accounting for the varying per-client delay, but I can&#39;t seem to make sense of the other values in the pa_timing_info struct.  The timestamp itself is not even close between clients (off by 1/3rd of a second or more and fluctuating), and pa_source_usec, though it fluctuates as well, doesn&#39;t account for the difference an any way that&#39;s more accurate than my gettimeofday() method.   Transport_usec seems to always be around 100us regardless, so it doesn&#39;t account for the timing difference between clients either.  Basically, I can&#39;t  do better than calling gettimofday() when the &quot;time stamp step&quot; occurs.  Can I count on this behavior?</div>
<div><br></div><div>The frustrating thing is that pulse seems to be capable of sub-millisecond timing (as evidenced by the close temporal proximity of callbacks in two separate clients), but nothing in the API can give me what I want.  I really don&#39;t want to give up since pulse provides so many other fantastic features, and is supported in many distributions by default.   I&#39;m thinking that I might be interested in working on the back end code that involves record stream timing.  Would you be able to point me to a starting place?</div>
<div><br></div><div>Thanks,</div><div>Matt<br>

<br><div class="gmail_quote">On Thu, Jun 2, 2011 at 10:51 AM, Colin Guthrie <span dir="ltr">&lt;<a href="mailto:gmane@colin.guthr.ie" target="_blank">gmane@colin.guthr.ie</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


&#39;Twas brillig, and Matt Robbins at 02/06/11 16:33 did gyre and gimble:<br>
<div><div></div><div>&gt; Hello Pulseaudio community,<br>
&gt;<br>
&gt; I&#39;m playing around with pulse to assess suitability for my project, and<br>
&gt; while it seems like I should be able to do what I want, I&#39;m struggling<br>
&gt; with the API.  Essentially, I need to record audio data with precise<br>
&gt; (~1ms) time stamps.  I&#39;m doing collaborative sound source localization<br>
&gt; between several machines, all synced to gps time.  Since I don&#39;t really<br>
&gt; need sample-accurate time, I figured it would be acceptable to call<br>
&gt; gettimeofday() on ALSA interrupts to get a pretty good idea of when the<br>
&gt; samples were recorded.  Since all of the machines will be using the same<br>
&gt; hardware, I don&#39;t even care if there&#39;s some fixed latency involved.<br>
&gt;  While doing this in ALSA would be an interesting project, when combined<br>
&gt; with some the other things I need to do (stream splitting, fixed-point<br>
&gt; resampling, etc.), it feels like I&#39;d be reinventing the wheel.  I&#39;ve<br>
&gt; been using JACK to accomplish what I need, but there are stability and<br>
&gt; support issues on the embedded systems I&#39;m using, so I&#39;m looking into<br>
&gt; alternatives, especially since the recent headless ubuntu release, which<br>
&gt; has a working pulse server by default :)<br>
&gt;<br>
&gt; I&#39;ve tried cobbling something together using the pacat.c source using<br>
&gt; pa_stream_set_read_callback().  My callback gets called, but although I<br>
&gt; call pa_stream_get_timing_info(), I can&#39;t see how to derive the<br>
&gt; information I need from the pa_timing_info struct because I can&#39;t see<br>
&gt; how the timestamp field is related to the current fragment.<br>
&gt;<br>
&gt; I&#39;m not even sure if I&#39;m going about this the right way, so if anyone<br>
&gt; who knows the system could give me a few pointers, I&#39;d really appreciate it.<br>
<br>
</div></div>I suspect you want to use:<br>
pa_stream_get_time().<br>
<br>
This returns the usecs since the stream started... this is likely what<br>
you want (IIUC).<br>
<br>
Cheers<br>
<br>
Col<br>
<br>
<br>
--<br>
<br>
Colin Guthrie<br>
gmane(at)<a href="http://colin.guthr.ie" target="_blank">colin.guthr.ie</a><br>
<a href="http://colin.guthr.ie/" target="_blank">http://colin.guthr.ie/</a><br>
<br>
Day Job:<br>
  Tribalogic Limited [<a href="http://www.tribalogic.net/" target="_blank">http://www.tribalogic.net/</a>]<br>
Open Source:<br>
  Mageia Contributor [<a href="http://www.mageia.org/" target="_blank">http://www.mageia.org/</a>]<br>
  PulseAudio Hacker [<a href="http://www.pulseaudio.org/" target="_blank">http://www.pulseaudio.org/</a>]<br>
  Trac Hacker [<a href="http://trac.edgewall.org/" target="_blank">http://trac.edgewall.org/</a>]<br>
<br>
_______________________________________________<br>
pulseaudio-discuss mailing list<br>
<a href="mailto:pulseaudio-discuss@lists.freedesktop.org" target="_blank">pulseaudio-discuss@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss" target="_blank">http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss</a><br>
</blockquote></div><br>
</div></div>