From: Mike Brady Date: Sat, 7 Oct 2017 19:49:32 +0000 (+0100) Subject: A little experimentation with dbus X-Git-Tag: 3.2d10~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=578981887e8a886897e56f9cac723e53d4bae21d;p=thirdparty%2Fshairport-sync.git A little experimentation with dbus --- diff --git a/dbus/src/dbus_service.c b/dbus/src/dbus_service.c index 20249053..1c87c03e 100644 --- a/dbus/src/dbus_service.c +++ b/dbus/src/dbus_service.c @@ -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() { diff --git a/dbus/src/org.gnome.ShairportSync.xml b/dbus/src/org.gnome.ShairportSync.xml index d4a8e3ac..b9f152b0 100644 --- a/dbus/src/org.gnome.ShairportSync.xml +++ b/dbus/src/org.gnome.ShairportSync.xml @@ -4,5 +4,7 @@ + + diff --git a/dbus/src/shairport-sync-dbus-client.c b/dbus/src/shairport-sync-dbus-client.c index cd917196..a5a03923 100644 --- a/dbus/src/shairport-sync-dbus-client.c +++ b/dbus/src/shairport-sync-dbus-client.c @@ -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);