[pulseaudio-discuss] Receiving signals from server in C

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Fri May 30 06:19:09 PDT 2014


On Fri, 2014-05-30 at 14:19 +0200, Greg Knoll wrote:
> This is my first time sending a message to this list, so I apologize
> if I do not follow the protocols correctly.
> 
> 
> I have successfully called other methods by first getting a DBUS
> session connection and using the server_lookup1 object.  However, I am
> having trouble receiving signals from the pulse server using the !
> ListenForSignal method in C/C++.    If I want, for instance, to listen
> for new modules.  The documentation says that the ListenForSignal
> method takes a string and an array of object paths as arguments,
> sa[o], but that the array can be empty to receive messages from all
> objects.
> 
> 
> So far I have this: 
> 
> 
>        msg = dbus_message_new_method_call(
>             "org.PulseAudio1", 				//Destination
>             "/org/pulseaudio/core1",                    //Object path to call on
>             "org.PulseAudio.Core1",                     //Interface to call on
>             "ListenForSignal");                         //Method
> 
> 
>     //Add arguments: s, []
>     dbus_message_iter_init_append(msg, &msgIter);
> 
>         //string
>         dbus_message_iter_append_basic(&msgIter, DBUS_TYPE_STRING,&signalName);
> 
>         //empty array to listen to all
>         dbus_message_iter_open_container(&msgIter,DBUS_TYPE_ARRAY,"o",&arrayIter);
>         dbus_message_iter_close_container(&msgIter, &arrayIter);
> 
> I don't get any errors from DBUS about incorrect signatures or objects not being found.  However, where/how do I listen for the signal?  I also tried setting a dbus match rule:
>      dbus_bus_add_match(system_bus, "type='signal',interface='org.PulseAudio.Core1'", &err);
> 
> 
> It listens on the system bus, but I've also tried listening on the pulse server session bus.  I still don't receive anything.

After reading the server address from the session bus, do you connect to
that address as instructed on [1]? I see the instructions aren't very
clear, but look at the Python example, you need to do that same thing in
your C code. It sounds like you're currently trying to use the session
bus for communicating with the server, but you are not supposed to do
that except for getting the server address in the beginning. The rest of
the communication is done via a peer-to-peer link.

[1] http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/DBus/ConnectingToServer/

-- 
Tanu



More information about the pulseaudio-discuss mailing list