[pulseaudio-discuss] Play/repeat a sample loaded on the pulseaudio server

Lennart Poettering lennart at poettering.net
Thu Dec 17 01:37:49 PST 2009


On Tue, 24.11.09 17:30, Joan Bertran (jbertran9 at gmail.com) wrote:

> I want to play a sound loaded on the pulseaudio server (a sample)
> and repeat it an arbitrary number of times in a loop.  I'm using
> pa_context_play_sample_with_proplist and detecting the end of play
> with pa_context_set_subscribe_callback with event type ==
> PA_SUBSCRIPTION_EVENT_SINK_INPUT and PA_SUBSCRIPTION_EVENT_REMOVE
> then pa_context_play_sample_with_proplist is called again (from the
> callback itself) but it has a noticeable delay between the end of
> the previous sound and the restart (i've tested it on Mandriva with
> pulse 0.9.15 and 0.9.19 and 0.9.21) I guess it could be done playing
> the sounds from the app itself but I find very handy and probably
> "faster" to put sounds into server memory and just play them.

That notification message you'll get when the stream's resources are
destroyed in the server, not when playback stops. On modern systems
where long hardware playback buffers are possible this usually means
that streams stay around up to 2s after they finished playing.

_EVENT_REMOVE is simply not useful for notifcation

> It would be great if pa_context_play_sample_with_proplist could
> especify a number to repeat the sound, perhaps a property into
> proplist.  So any feedback on the idea and orientation on how to
> implement the loop?

As Marc-Andre pointed out we definitely want this implemented natively
in both libcanberra and PA. However this is actually more complex as
it sounds. First of all, we need to track clients so that a client
cannot start a looped event sound and then go away and we continue to
play that for all eternity. Currently, for event sounds we dont keep
track of clients.

Also, I am still wondering if we might need more than simple looping,
i.e. a prefix and a postfix sound as well...

But yes, instead of cooking your own hacky client-side version of this
I'd really like to see this properly integrated into the PA server.

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