[pulseaudio-discuss] Writing mono bindings - what is pa_operation actually used for?

Christopher James Halse Rogers raof at ubuntu.com
Sat Aug 1 17:30:31 PDT 2009


On Tue, 2009-07-28 at 16:45 +0200, Lennart Poettering wrote:
> On Tue, 28.07.09 15:54, Christopher James Halse Rogers (raof at ubuntu.com) wrote:
> 
> > I'm (slowly) writing some mono/CLI bindings for pulseaudio, with the
> > initial goal of writing or enabling a GNOME Do plugin for adjusting the
> > volume and manipulating streams.  Since that touches a wide swathe of
> > the API anyway, I plan to go on and bind everything.
> 
> Sounds good!
> 
> > However, I don't understand what pa_operation is good for.  As far as I
> > can see, you can't wait on a pa_operation, so they're not particularly
> > useful for completion notification - and every call I've looked at has
> > some other method of signalling completion anyway.  The docs also say
> > that you can't depend on a cancel call working, so that also seems a
> > little pointless, and you can't determine success or failure of a call
> > from a pa_operation.
> 
> The point of pa_operation is that you can have multiple requests
> outstanding asynchronously. And of course, you *can* wait for
> completion with them. Simply let the event loop running until the
> operation obvject left the PA_OPERATION_RUNNING state.

So you'd be doing a 
while(state == PA_OPERATION_RUNNING) {
 iterate_mainloop ()
}
style loop.  I hadn't really considered this.  I was expecting a
callback, but this makes more sense.
> 
> In some cases it makes sense to wait for completion of operations, in
> others it doesn't. In many situations it hence makes sense to do a
> loop as suggested above, in others it is fine to _unref the operation
> right after starting it, because you are not interested in the completion.
> 
> The callback functions are bound to the pa_operation object. So you
> can cancel a callback by issuing pa_operation_cancel() and you won't
> get any callback for it anymore. What the docs say is that the cancel
> won't necessarily stop the operation itself, but it will still disable
> the callback. This is very often very important to use since it allows
> you to make sure to drop all userdata pointers to some specific object
> when you are destroying it.

Right.  *This* part is definitely useful; the docs I read didn't make it
obvious that it'd definitely cancel the callback.  I'll try to submit a
doc patch making this clear.

That's given me a clear idea of what pa_operation is about, and how I'll
need to bind it.

Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20090802/16998d92/attachment.pgp>


More information about the pulseaudio-discuss mailing list