[pulseaudio-discuss] Querying the number of samples played

Pierre Ossman ossman at cendio.se
Tue Feb 13 23:50:33 PST 2007

Kevin Mescher wrote:
> Thanks for the quick response.  PulseAudio looks like a very robust API,
> and
> the cross-platform nature makes my job MUCH easier.

Np. You shouldn't top post though, terribly annoying.

> I'm going to do a sanity check on my thinking here:
> Where each frame is a single sample from one or more channels:
> The number of "samples" (in this case, frames) = pa_get_stream_time(...) *
> sampling_rate / 1000000

Yes, but with the slight error that you do not use the return value from
pa_get_stream_time(). (you use r_usec).

> to save on network traffic?

They are usually a good idea if you want stable latency values.

> For later development, I'd like to change the model to this:
> 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.
> 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?

I'd suggest using a pull model. You tell pulse to use a buffer size of
325 ms, then give it as much data as it asks for (via the callbacks).

Pierre Ossman            OpenSource-based Thin Client Technology
System Developer         Telephone: +46-13-21 46 00
Cendio AB                Web: http://www.cendio.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20070214/039351da/attachment.pgp>

More information about the pulseaudio-discuss mailing list