From: Mike Brady Date: Fri, 8 Feb 2019 22:31:50 +0000 (+0000) Subject: Add call to check if the dbus service is started. X-Git-Tag: 3.3RC0~66^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97a4766e93c73e741b6ea4682f4e80ad14076d8a;p=thirdparty%2Fshairport-sync.git Add call to check if the dbus service is started. --- diff --git a/activity_monitor.c b/activity_monitor.c index 2d418d6d..697bec95 100644 --- a/activity_monitor.c +++ b/activity_monitor.c @@ -67,13 +67,18 @@ void going_active(int block) { #endif #ifdef CONFIG_DBUS_INTERFACE + if (dbus_service_is_running()) 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 + if (dbus_service_is_running()) shairport_sync_set_disable_standby(SHAIRPORT_SYNC(shairportSyncSkeleton), TRUE); + else + config.keep_dac_busy = 1; +#else + config.keep_dac_busy = 1; #endif } } @@ -89,13 +94,18 @@ void going_inactive(int block) { #endif #ifdef CONFIG_DBUS_INTERFACE + if (dbus_service_is_running()) 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 + if (dbus_service_is_running()) shairport_sync_set_disable_standby(SHAIRPORT_SYNC(shairportSyncSkeleton), FALSE); + else + config.keep_dac_busy = 0; +#else + config.keep_dac_busy = 0; #endif } } diff --git a/audio_alsa.c b/audio_alsa.c index ef65a345..9658832a 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -1533,7 +1533,12 @@ void alsa_buffer_monitor_thread_cleanup_function(__attribute__((unused)) void */ void *alsa_buffer_monitor_thread_code(__attribute__((unused)) void *arg) { + int okb = -1; while (1) { + if (okb != config.keep_dac_busy) { + debug(1,"keep_dac_busy is now %d",config.keep_dac_busy); + okb = config.keep_dac_busy; + } if ((config.keep_dac_busy != 0) && (alsa_device_initialised == 0)) { debug(2, "alsa: alsa_buffer_monitor_thread_code() calling " "do_alsa_device_init_if_needed."); diff --git a/dbus-service.c b/dbus-service.c index c6156cb5..8656d919 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -15,6 +15,8 @@ #include "dbus-service.h" +int service_is_running = 0; + ShairportSyncDiagnostics *shairportSyncDiagnosticsSkeleton = NULL; ShairportSyncRemoteControl *shairportSyncRemoteControlSkeleton = NULL; ShairportSyncAdvancedRemoteControl *shairportSyncAdvancedRemoteControlSkeleton = NULL; @@ -841,6 +843,7 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name debug(1, "Shairport Sync native D-Bus service started at \"%s\" on the %s bus.", name, (config.dbus_service_bus_type == DBT_session) ? "session" : "system"); + service_is_running = 1; } static void on_dbus_name_lost_again(__attribute__((unused)) GDBusConnection *connection, @@ -887,4 +890,9 @@ void stop_dbus_service() { g_bus_unown_name(ownerID); else debug(1, "Zero OwnerID for \"org.gnome.ShairportSync\"."); + service_is_running = 0; +} + +int dbus_service_is_running() { + return service_is_running; } diff --git a/dbus-service.h b/dbus-service.h index a00d06e0..5cfc02e2 100644 --- a/dbus-service.h +++ b/dbus-service.h @@ -7,5 +7,6 @@ ShairportSync *shairportSyncSkeleton; int start_dbus_service(); void stop_dbus_service(); +int dbus_service_is_running(); #endif /* #ifndef DBUS_SERVICE_H */