summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-11-28 03:49:43 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2012-11-28 03:49:43 +0100
commit6e19430d7bdd16ba593e2999014cae07d88ad688 (patch)
tree7afd36e0544c54cf2912b598cb33a17eeb176483
parentb2b221912c6c301d76ca88b298c772cf762fad55 (diff)
downloadpulse-volume-change-notify-6e19430d7bdd16ba593e2999014cae07d88ad688.tar.gz
pulse-volume-change-notify-6e19430d7bdd16ba593e2999014cae07d88ad688.tar.xz
pulse-volume-change-notify-6e19430d7bdd16ba593e2999014cae07d88ad688.zip
add volume values into dbus signal
-rw-r--r--module-volume-change-notify.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/module-volume-change-notify.c b/module-volume-change-notify.c
index b45e27e..255aa92 100644
--- a/module-volume-change-notify.c
+++ b/module-volume-change-notify.c
@@ -41,6 +41,34 @@ struct userdata {
DBusConnection *dbus_connection;
};
+dbus_bool_t add_volumes(DBusMessageIter *args, const pa_cvolume *vol)
+{
+ DBusMessageIter array;
+ char buf[] = { DBUS_TYPE_UINT16, 0};
+ const pa_volume_t *values;
+ uint8_t channel;
+
+ if (!dbus_message_iter_open_container (args, DBUS_TYPE_ARRAY,
+ buf, &array))
+ return FALSE;
+
+ for (channel = 0; channel < vol->channels; channel++) {
+ uint16_t volume = (vol->values[channel] * 100 + PA_VOLUME_NORM / 2) /
+ PA_VOLUME_NORM;
+
+ if (!dbus_message_iter_append_basic(&array, DBUS_TYPE_UINT16,
+ &volume)) {
+ dbus_message_iter_abandon_container (args, &array);
+ return FALSE;
+ }
+ }
+
+ if (!dbus_message_iter_close_container (args, &array))
+ return FALSE;
+
+ return TRUE;
+}
+
void send_dbus_signal(const char *name, const pa_cvolume *vol,
const struct userdata *u)
{
@@ -59,6 +87,9 @@ void send_dbus_signal(const char *name, const pa_cvolume *vol,
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &name))
goto fail;
+ if (!add_volumes(&args, vol))
+ goto fail;
+
/* send the message and flush the connection */
if (!dbus_connection_send(u->dbus_connection, msg, NULL))
goto fail;