]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add call to check if the dbus service is started.
authorMike Brady <mikebrady@eircom.net>
Fri, 8 Feb 2019 22:31:50 +0000 (22:31 +0000)
committerMike Brady <mikebrady@eircom.net>
Fri, 8 Feb 2019 22:31:50 +0000 (22:31 +0000)
activity_monitor.c
audio_alsa.c
dbus-service.c
dbus-service.h

index 2d418d6dfc4a60f5f541f15960ce96da03f21762..697bec9587db0ddf454f2687e0c018c9711d0bc6 100644 (file)
@@ -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
   }
 }
index ef65a345ce26a38f82147171d0723993c78d1b01..9658832a5cd031f0a3304f1783e023c1f80c9c80 100644 (file)
@@ -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.");
index c6156cb5c4202135c09adc52a8336c0ebce0e70b..8656d91913eedde6055fba89d4372ae77795b75e 100644 (file)
@@ -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;
 }
index a00d06e0f6aeb5a1f6717dbc0c4f24bf767c8d47..5cfc02e2dcfac67a49cf8fcf0924e6eab7d9cde0 100644 (file)
@@ -7,5 +7,6 @@ ShairportSync *shairportSyncSkeleton;
 
 int start_dbus_service();
 void stop_dbus_service();
+int dbus_service_is_running();
 
 #endif /* #ifndef DBUS_SERVICE_H */