]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
A little experimentation with dbus
authorMike Brady <mikebrady@eircom.net>
Sat, 7 Oct 2017 19:49:32 +0000 (20:49 +0100)
committerMike Brady <mikebrady@eircom.net>
Sat, 7 Oct 2017 19:49:32 +0000 (20:49 +0100)
dbus/src/dbus_service.c
dbus/src/org.gnome.ShairportSync.xml
dbus/src/shairport-sync-dbus-client.c

index 20249053d4323db245f6fb96b41665a0aa9e2615..1c87c03e749f459a277155c2d0c93a08e758def7 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "dbus_service.h"
 
-void notify_loudness_filter_active_callback(ShairportSync *skeleton, gpointer user_data) {
+gboolean notify_loudness_filter_active_callback(ShairportSync *skeleton, gpointer user_data) {
   debug(1, "\"notify_loudness_filter_active_callback\" called.");
   if (shairport_sync_get_loudness_filter_active(skeleton)) {
     debug(1, "activating loudness filter");
@@ -17,9 +17,10 @@ void notify_loudness_filter_active_callback(ShairportSync *skeleton, gpointer us
     debug(1, "deactivating loudness filter");
     config.loudness = 0;
   }
+  return TRUE;
 }
 
-void notify_loudness_threshold_callback(ShairportSync *skeleton, gpointer user_data) {
+gboolean notify_loudness_threshold_callback(ShairportSync *skeleton, gpointer user_data) {
   gdouble th = shairport_sync_get_loudness_threshold(skeleton);
   if ((th <= 0.0) && (th >= -100.0)) {
     debug(1, "Setting loudness threshhold to %f.", th);
@@ -27,9 +28,10 @@ void notify_loudness_threshold_callback(ShairportSync *skeleton, gpointer user_d
   } else {
     debug(1, "Invalid loudness threshhold: %f. Ignored.", th);
   }
+  return TRUE;
 }
 
-void notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
+gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
   gdouble vo = shairport_sync_get_volume(skeleton);
   if (((vo <= 0.0) && (vo >= -30.0)) || (vo == -144.0)) {
     debug(1, "Setting volume to %f.", vo);
@@ -40,6 +42,13 @@ void notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
   } else {
     debug(1, "Invalid volume: %f -- ignored.", vo);
   }
+  return TRUE;
+}
+
+static gboolean on_handle_vol_up(ShairportSync *skeleton, GDBusMethodInvocation *invocation, gpointer user_data) {
+  debug(1,"VolUp");
+  shairport_sync_complete_vol_up(skeleton,invocation);
+  return TRUE;
 }
 
 static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) {
@@ -66,6 +75,7 @@ static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpo
   g_signal_connect(skeleton, "notify::loudness-threshold",
                    G_CALLBACK(notify_loudness_threshold_callback), NULL);
   g_signal_connect(skeleton, "notify::volume", G_CALLBACK(notify_volume_callback), NULL);
+  g_signal_connect(skeleton, "handle-vol-up", G_CALLBACK(on_handle_vol_up), NULL);
 }
 
 int start_dbus_service() {
index d4a8e3ac35e37a4b69b7ef43a7582014e0dd37d1..b9f152b0d8ca9b0fc4fdf1c9bdbfcd347fcf8a65 100644 (file)
@@ -4,5 +4,7 @@
     <property name="LoudnessFilterActive" type="b" access="readwrite" />
     <property name="LoudnessThreshold" type="d" access="readwrite" />
     <property name="Volume" type="d" access="readwrite" />
+    <method name="VolUp">
+    </method>
   </interface>
 </node>
index cd917196b447c6ad07abd126fbc68c5c25c1ffbb..a5a039236e7554ab967f1eab96903cde1469f8f7 100644 (file)
@@ -87,26 +87,27 @@ void main(void) {
   g_signal_connect(proxy, "notify::volume", G_CALLBACK(notify_volume_callback), NULL);
 
   g_print("Starting test...\n");
-
   shairport_sync_set_volume(SHAIRPORT_SYNC(proxy), -20.0);
-  sleep(10);
+  sleep(1);
   shairport_sync_set_volume(SHAIRPORT_SYNC(proxy), -10.0);
-  sleep(10);
+  sleep(1);
   shairport_sync_set_volume(SHAIRPORT_SYNC(proxy), 0.0);
-  sleep(10);
-
+  sleep(1);
   shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), FALSE);
-  sleep(15);
+  sleep(1);
   shairport_sync_set_loudness_threshold(SHAIRPORT_SYNC(proxy), -20.0);
+  sleep(1);
   shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), TRUE);
-  sleep(15);
+  sleep(1);
   shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), FALSE);
-  sleep(5);
+  sleep(1);
   shairport_sync_set_loudness_threshold(SHAIRPORT_SYNC(proxy), -10.0);
   shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), TRUE);
-  sleep(15);
+  sleep(1);
   shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), TRUE);
-  sleep(15);
+  sleep(1);
+  shairport_sync_call_vol_up(SHAIRPORT_SYNC(proxy), NULL,NULL,NULL);
+  sleep(5);
   g_print("Finished test...\n");
   g_main_loop_quit(loop);
   pthread_join(dbus_thread, NULL);