[pulseaudio-discuss] Very strange behavior in pa_simple API test

Lennart Poettering lennart at poettering.net
Thu Dec 24 09:41:07 PST 2009


On Sun, 20.12.09 17:15, Bill Cox (waywardgeek at gmail.com) wrote:

> I wrote a super-simple test using the pa_simple API.  I have some
> sound data in a static array.  I call getchar(), and then call
> pa_simple_write, in an infinite loop.  When I run this, and just hit
> enter several times, I expect to hear the sound played once each time
> I press enter.  Instead, it plays nothing the first time, but then
> plays it twice the second time I press enter, nothing the third time,
> twice on the fourth and so on.
> 
> I ran this in gdb, and saw something super-strange.  The first two
> times pa_simple_write was called, no sounds was played.  However, when
> the next call the getchar() was made, both sounds played!  Somehow
> getchar() is interacting with the sound queues!

You should not make assumptions on the starting threshold. Either
configure it manually, or manually flush the buffers when you need it
or write silence PCM samples when you need silence (which is what I'd
recommend).

If a manual flush is not available in your API it might be a good diea
to close/reopen th device.

Lennart

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



More information about the pulseaudio-discuss mailing list