[pulseaudio-discuss] Async API - need some help

Zeno Endemann zeno.endemann at googlemail.com
Sat Jun 18 14:29:32 PDT 2011


Hello everyone,

I've written a small Qt application for pulseaudio latency testing. It
already somewhat works, but I still have a few issues:

1. The following code fragment works (audio is played):
    int16_t *buf = (int16_t *)malloc(nbytes);
    writeToneToBuffer(buf, nbytes/4, ...);
    pa_stream_write(p, buf, (nbytes/4)*4, 0, 0, PA_SEEK_RELATIVE );
    free(buf);
whereas this does not:
    int16_t *buf = 0;
    pa_stream_begin_write(p, (void **)&buf, &nbytes);
    writeToneToBuffer(buf, nbytes/4, ...);
    pa_stream_write(p, buf, (nbytes/4)*4, 0, 0, PA_SEEK_RELATIVE );
There is no error reported, just no audio is played. Do I need to do
something else?

2. I figure it should be possible to react fast to user input even when
the playback buffers are big by overwriting already written buffers with
pa_stream_write(..., buf, ..., offset, PA_SEEK_RELATIVE_ON_READ). But
how big can/should buf and offset be? So far I haven't been able to get
good results with this (either underruns are reported or the latency
remains quite bad).

3. To print out latency measurements I use the following code:
   if( pa_stream_get_latency(cs->pa_Strm, &l, &neg) == PA_ERR_NODATA )
     qDebug("error: no data");
   else
     qDebug("Latency: %d", (int)l);
but this always gives me weird, much too big numbers.

I've uploaded the full code here (needs Qt and Linux):
http://www2.informatik.hu-berlin.de/~endemann/PulseStress_0.1.tar.bz2

Would be great if someone can help me with this.

Thanks,
Zeno


More information about the pulseaudio-discuss mailing list