From 34351a99cb17014c9e8c0172ddbec734da038109 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Fri, 8 Feb 2019 16:57:39 +0000 Subject: [PATCH] Continue hooking up active mode and disable standby stuff --- activity_monitor.c | 23 ++++++++++++++++ dbus-service.c | 55 ++++++++++++++++++++++++++++++++++++- org.gnome.ShairportSync.xml | 2 ++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/activity_monitor.c b/activity_monitor.c index 94321f8b..796e3ed0 100644 --- a/activity_monitor.c +++ b/activity_monitor.c @@ -40,6 +40,7 @@ #include "activity_monitor.h" #include "common.h" +#include "dbus-service.h" #include "rtsp.h" enum am_state state; @@ -60,6 +61,17 @@ void going_active(int block) { debug(2, "abeg"); // active mode begin send_ssnc_metadata('pend', NULL, 0, 1); // contains cancellation points #endif + +#ifdef CONFIG_DBUS_INTERFACE + shairport_sync_set_active(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE); +#endif + + if (config.disable_standby_mode == disable_standby_while_active) { + config.keep_dac_busy = 1; +#ifdef CONFIG_DBUS_INTERFACE + shairport_sync_set_disable_standby(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE); +#endif + } } void going_inactive(int block) { @@ -71,6 +83,17 @@ void going_inactive(int block) { debug(2, "aend"); // active mode end send_ssnc_metadata('pend', NULL, 0, 1); // contains cancellation points #endif + +#ifdef CONFIG_DBUS_INTERFACE + shairport_sync_set_active(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); +#endif + + if (config.disable_standby_mode == disable_standby_while_active) { + config.keep_dac_busy = 0; +#ifdef CONFIG_DBUS_INTERFACE + shairport_sync_set_disable_standby(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); +#endif + } } void activity_monitor_signify_activity(int active) { diff --git a/dbus-service.c b/dbus-service.c index 59fdd2c0..c6156cb5 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -430,6 +430,36 @@ gboolean notify_drift_tolerance_callback(ShairportSync *skeleton, return TRUE; } +gboolean notify_disable_standby_mode_callback(ShairportSync *skeleton, + __attribute__((unused)) gpointer user_data) { + char *th = (char *)shairport_sync_get_disable_standby_mode(skeleton); + if ((strcasecmp(th, "no") == 0) || (strcasecmp(th, "off") == 0) || (strcasecmp(th, "never") == 0)) { + config.disable_standby_mode = disable_standby_off; + config.keep_dac_busy = 0; + } else if ((strcasecmp(th, "yes") == 0) || (strcasecmp(th, "on") == 0) || (strcasecmp(th, "always") == 0)) { + config.disable_standby_mode = disable_standby_always; + config.keep_dac_busy = 1; + } else if (strcasecmp(th, "while active") == 0) + config.disable_standby_mode = disable_standby_while_active; + else { + warn("An unrecognised disable_standby_mode: \"%s\" was requested via D-Bus interface.", th); + switch (config.disable_standby_mode) { + case disable_standby_off: + shairport_sync_set_disable_standby_mode(skeleton, "off"); + break; + case disable_standby_always: + shairport_sync_set_disable_standby_mode(skeleton, "always"); + break; + case disable_standby_while_active: + shairport_sync_set_disable_standby_mode(skeleton, "while active"); + break; + default: + break; + } + } + return TRUE; +} + gboolean notify_alacdecoder_callback(ShairportSync *skeleton, __attribute__((unused)) gpointer user_data) { char *th = (char *)shairport_sync_get_alacdecoder(skeleton); @@ -622,7 +652,9 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name G_CALLBACK(notify_interpolation_callback), NULL); g_signal_connect(shairportSyncSkeleton, "notify::alacdecoder", G_CALLBACK(notify_alacdecoder_callback), NULL); - g_signal_connect(shairportSyncSkeleton, "notify::volume-control-profile", + g_signal_connect(shairportSyncSkeleton, "notify::disable-standby-mode", + G_CALLBACK(notify_disable_standby_mode_callback), NULL); + g_signal_connect(shairportSyncSkeleton, "notify::volume-control-profile", G_CALLBACK(notify_volume_control_profile_callback), NULL); g_signal_connect(shairportSyncSkeleton, "notify::disable-standby", G_CALLBACK(notify_disable_standby_callback), NULL); @@ -706,6 +738,27 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name #endif + shairport_sync_set_active(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); + debug(1, ">> Active set to \"false\""); + + switch (config.disable_standby_mode) { + case disable_standby_off: + shairport_sync_set_disable_standby_mode(SHAIRPORT_SYNC(shairportSyncSkeleton), "off"); + debug(1, ">> disable standby mode set to \"off\""); + break; + case disable_standby_always: + shairport_sync_set_disable_standby_mode(SHAIRPORT_SYNC(shairportSyncSkeleton), "always"); + debug(1, ">> disable standby mode set to \"always\""); + break; + case disable_standby_while_active: + shairport_sync_set_disable_standby_mode(SHAIRPORT_SYNC(shairportSyncSkeleton), "while active"); + debug(1, ">> disable standby mode set to \"while active\""); + break; + default: + debug(1,"invalid disable_standby mode!"); + break; + } + #ifdef CONFIG_SOXR if (config.packet_stuffing == ST_basic) { shairport_sync_set_interpolation(SHAIRPORT_SYNC(shairportSyncSkeleton), "basic"); diff --git a/org.gnome.ShairportSync.xml b/org.gnome.ShairportSync.xml index 279e4f0a..cea574bc 100644 --- a/org.gnome.ShairportSync.xml +++ b/org.gnome.ShairportSync.xml @@ -2,7 +2,9 @@ + +