From: Mike Brady Date: Fri, 8 Feb 2019 09:04:33 +0000 (+0000) Subject: Starting to connect active mode with disable standby. X-Git-Tag: 3.3RC0~66^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c86823c343a70f6106fd71e314255a8fce978e4d;p=thirdparty%2Fshairport-sync.git Starting to connect active mode with disable standby. --- diff --git a/activity_monitor.c b/activity_monitor.c index 86af012a..94321f8b 100644 --- a/activity_monitor.c +++ b/activity_monitor.c @@ -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); diff --git a/activity_monitor.h b/activity_monitor.h index 9de33454..d9e1ffd6 100644 --- a/activity_monitor.h +++ b/activity_monitor.h @@ -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 diff --git a/audio_alsa.c b/audio_alsa.c index 2fd4497d..4cb187b2 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -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 diff --git a/common.h b/common.h index 870cb1a6..e13ebf9e 100644 --- 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)