Thanks for the quick response. PulseAudio looks like a very
robust API, and the cross-platform nature makes my job MUCH easier.<br>
<br>
<br>
I'm going to do a sanity check on my thinking here:<br>
<br>
Where each frame is a single sample from one or more channels:<br>
<br>
The number of "samples" (in this case, frames) = pa_get_stream_time(...) * sampling_rate / 1000000<br>
<br>
So instead of using info.play.samples, I would use the above formula.<br>
<br>
The program was mostly written to play data at an 8kHz sampling rate,
so 1000 samples was 325msec. I may adjust it to try and load
325msec of data, no matter what the sampling rate is. I may use
the stream latency to adjust the amount to send.<br>
<br>
Should I use PA_STREAM_INTERPOLATE_TIMING and PA_STREAM_AUTO_TIMING_UPDATE to save on network traffic?<br>
<br>
The current model of the application is not very good. Later on,
I may recode to use the pa_mainloop API, and only send data when
required. Currently the model goes like this:<br>
<br>
XtAppMainLoop runs the playback procedure every iteration. The
playback procedure has a hard delay built in (I'm guessing) to regulate
the speed of the loop. The playback queries the audio device to
see if there less than 1000 samples to be played. If there are,
load an additional 1000 samples and update the waveform marker.<br>
<br>
For later development, I'd like to change the model to this:<br>
<br>
In the playback procedure, run pa_mainloop_iterate, and use a
pa_stream_write callback to set the "needs more data" flag, rather than
using a sample count method. If the flag is set, send more data,
and update the waveform marker.<br>
<br>
When loading data, I would send (325 + msec_latency) msec worth of
data. Or is there a way to calculate the optimum chunk size to
send?<br>
<br><br><div><span class="gmail_quote">On 2/13/07, <b class="gmail_sendername">Pierre Ossman</b> <<a href="mailto:ossman@cendio.se">ossman@cendio.se</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Kevin Mescher wrote:<br>><br>> The application sent data synchronously to the audio device, and used the<br>> sample count (accessed via Solaris' info.play.samples) to determine<br>> where to<br>> put the marker on its waveform display. It was pretty simple, and the
<br>> logic<br>> went:<br><br>The equivalent of info.play.samples is pa_stream_get_time(). Note the<br>comments about it though:<br><br>/** Return the current playback/recording time. This is based on the<br> * data in the timing info structure returned by
<br> * pa_stream_get_timing_info(). This function will usually only return<br> * new data if a timing info update has been recieved. Only if timing<br> * interpolation has been requested (PA_STREAM_INTERPOLATE_TIMING)<br>
* the data from the last timing update is used for an estimation of<br> * the current playback/recording time based on the local time that<br> * passed since the timing info structure has been acquired. The time<br> * value returned by this function is guaranteed to increase
<br> * monotonically. (that means: the returned value is always greater or<br> * equal to the value returned on the last call) This behaviour can<br> * be disabled by using PA_STREAM_NOT_MONOTONOUS. This may be<br> * desirable to deal better with bad estimations of transport
<br> * latencies, but may have strange effects if the application is not<br> * able to deal with time going 'backwards'. \since 0.6 */<br><br>><br>> if there are less than 1000 samples remaining to be played (samples sent -
<br>> the value of info.play.samples), send more data.<br>><br><br>Now this is a bad model. 1000 samples is just 23 ms at 44100 Hz, a delay<br>that is easily achievable on a network.<br><br>Rgds<br>--<br>Pierre Ossman OpenSource-based Thin Client Technology
<br>System Developer Telephone: +46-13-21 46 00<br>Cendio
AB Web:
<a href="http://www.cendio.com">http://www.cendio.com</a><br><br><br>_______________________________________________<br>pulseaudio-discuss mailing list<br><a href="mailto:pulseaudio-discuss@mail.0pointer.de">pulseaudio-discuss@mail.0pointer.de
</a><br><a href="https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss">https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss</a><br><br><br></blockquote></div><br>