summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-11-28 03:49:21 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2012-11-28 03:49:21 +0100
commitb2b221912c6c301d76ca88b298c772cf762fad55 (patch)
treeafd0011d435a3b1706c2938c58991e8d86dd3917
parent4fbb958501a0826cbcccb04965b002a318d89098 (diff)
downloadpulse-volume-change-notify-b2b221912c6c301d76ca88b298c772cf762fad55.tar.gz
pulse-volume-change-notify-b2b221912c6c301d76ca88b298c772cf762fad55.tar.xz
pulse-volume-change-notify-b2b221912c6c301d76ca88b298c772cf762fad55.zip
send dbus signal with interface name
-rw-r--r--module-volume-change-notify.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/module-volume-change-notify.c b/module-volume-change-notify.c
index 6032d17..b45e27e 100644
--- a/module-volume-change-notify.c
+++ b/module-volume-change-notify.c
@@ -41,6 +41,35 @@ struct userdata {
DBusConnection *dbus_connection;
};
+void send_dbus_signal(const char *name, const pa_cvolume *vol,
+ const struct userdata *u)
+{
+ DBusMessage* msg;
+ DBusMessageIter args;
+
+ /* create a signal and check for errors */
+ msg = dbus_message_new_signal("/org/PulseAudio/VolumeNotification",
+ "org.PulseAudio.VolumeNotification",
+ "VolumeChange");
+ if (!msg)
+ return;
+
+ /* append arguments onto signal */
+ dbus_message_iter_init_append(msg, &args);
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &name))
+ goto fail;
+
+ /* send the message and flush the connection */
+ if (!dbus_connection_send(u->dbus_connection, msg, NULL))
+ goto fail;
+
+ dbus_connection_flush(u->dbus_connection);
+
+fail:
+ /* free the message */
+ dbus_message_unref(msg);
+}
+
void sink_change_event_cb(pa_core *c, pa_subscription_event_type_t t,
uint32_t idx, void *userdata)
{
@@ -49,10 +78,14 @@ void sink_change_event_cb(pa_core *c, pa_subscription_event_type_t t,
if (PA_SUBSCRIPTION_EVENT_CHANGE & t == 0)
return;
+ if (!userdata)
+ return;
+
s = pa_idxset_get_by_index(c->sinks, idx);
if (!s)
return;
+ send_dbus_signal(s->name, &s->reference_volume, userdata);
}
void pa__done(pa_module *m)