[pulseaudio-discuss] Problem using the Simple API

Lennart Poettering lennart at poettering.net
Fri Oct 30 18:23:31 PDT 2009

On Fri, 30.10.09 18:07, eric (ekilfoil at gmail.com) wrote:

> On Fri, Oct 30, 2009 at 5:49 PM, Lennart Poettering
> <lennart at poettering.net>wrote:
> > I am sorry, but I still have not understood what exactly is happening
> > that you don't expect to be happening, resp. what exactly is not
> > happening that you expect to happen.
>  I'm not sure how to better explain it.... I open a stream, read from it,
> write to a pipe, and close the stream.  The problem is that pa_simple_read()
> is returning immediately instead of giving me 640 bytes of PCM.

Returning immediately *instead* of giving you 640 bytes of PCM?

I mean, are you suggesting that pa_simple_read() is in fact *not*
returning 640 bytes?

Or is your confusion simply because you expect that at 44khz you
expect that calling pa_simple_read() for 640 bytes will block for
exactly 3.6 ms? That's not how things work. If it did you'd get
dropouts in the time between two _read() calls.

if you want to do time synchronization, then query for the *time*,
don't count samples. The time will be independant of buffering and so
on. In the simple API there is pa_simple_get_latency() which you can
query before you read something and which will then tell you how much
earlier what you will read next was actually recorded.

If you use the complex API then you can use pa_stream_get_time() to
get a stream time, relative to the beginning of the stream.


Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4

More information about the pulseaudio-discuss mailing list