]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Starting to connect active mode with disable standby.
authorMike Brady <mikebrady@eircom.net>
Fri, 8 Feb 2019 09:04:33 +0000 (09:04 +0000)
committerMike Brady <mikebrady@eircom.net>
Fri, 8 Feb 2019 09:04:33 +0000 (09:04 +0000)
activity_monitor.c
activity_monitor.h
audio_alsa.c
common.h

index 86af012a616eb94a4cbe38eac799e1d3ba722262..94321f8bc0156bb327f91223e2977b53f761aad6 100644 (file)
@@ -42,7 +42,7 @@
 #include "common.h"
 #include "rtsp.h"
 
-enum am_state { am_inactive, am_active, am_timing_out } state;
+enum am_state state;
 enum ps_state { ps_inactive, ps_active } player_state;
 
 int activity_monitor_running = 0;
@@ -217,6 +217,10 @@ void *activity_monitor_thread_code(void *arg) {
   pthread_exit(NULL);
 }
 
+enum am_state activity_status() {
+  return (state);
+}
+
 void activity_monitor_start() {
   // debug(1,"activity_monitor_start");
   pthread_create(&activity_monitor_thread, NULL, activity_monitor_thread_code, NULL);
index 9de334546710908b0d77fdc621c23c91984057c9..d9e1ffd69f2ef0828e2861a8469cbbccfce1b783 100644 (file)
@@ -1,4 +1,8 @@
 #pragma once
+
+enum am_state { am_inactive, am_active, am_timing_out };
+
 void activity_monitor_start();
 void activity_monitor_stop();
 void activity_monitor_signify_activity(int active); // 0 means inactive, non-zero means active
+enum am_state activity_status(); // true if non inactive; false if inactive
index 2fd4497d557111322906562021e21f01eab9d223..4cb187b291df4eee22dc5c4d78cdd30e9e59bb36 100644 (file)
@@ -975,12 +975,26 @@ static int init(int argc, char **argv) {
       }
     }
 
-    // Get the optional "Keep DAC Busy setting"
-    int kdb;
-    if (config_set_lookup_bool(config.cfg, "alsa.disable_standby_mode", &kdb)) {
-      config.keep_dac_busy = kdb;
+
+    /* Get the optional disable_standby_mode setting. */
+    config.disable_standby_mode = disable_standby_while_active;
+    config.keep_dac_busy = 0;
+    if (config_lookup_string(config.cfg, "alsa.disable_standby_mode", &str)) {
+      if ((strcasecmp(str, "no") == 0) || (strcasecmp(str, "off") == 0) || (strcasecmp(str, "never") == 0))
+        config.disable_standby_mode = disable_standby_off;
+      else if ((strcasecmp(str, "yes") == 0) || (strcasecmp(str, "on") == 0) || (strcasecmp(str, "always") == 0)) {
+        config.disable_standby_mode = disable_standby_on;
+        config.keep_dac_busy = 1;
+      } else if (strcasecmp(str, "while active") == 0)
+        config.disable_standby_mode = disable_standby_while_active;
+      else {
+        warn("Invalid disable_standby_mode option choice \"%s\". It should be "
+             "\"always\", \"while active\" or \"never\". "
+             "It is set to \"while active\".");
+      }
     }
-    debug(1, "alsa: disable_standby_mode is %s.", config.keep_dac_busy ? "on" : "off");
+
+    debug(1, "alsa: disable_standby_mode is %d.", config.disable_standby_mode);
   }
 
   optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
index 870cb1a6aab91b03fcad738492d87369b735099e..e13ebf9e5a43cd4510c956708714e25a866e6ffa 100644 (file)
--- a/common.h
+++ b/common.h
@@ -62,6 +62,12 @@ enum decoders_supported_type {
   decoder_apple_alac,
 } decoders_supported_type;
 
+enum disable_standby_mode_type {
+  disable_standby_off = 0,
+  disable_standby_while_active,
+  disable_standby_always
+}
+
 // the following enum is for the formats recognised -- currently only S16LE is recognised for input,
 // so these are output only for the present
 
@@ -201,6 +207,7 @@ typedef struct {
   float loudness_reference_volume_db;
   int alsa_use_hardware_mute;
   double alsa_maximum_stall_time;
+  enum disable_standby_mode_type disable_standby_mode;
   volatile int keep_dac_busy;
 
 #if defined(CONFIG_DBUS_INTERFACE)