Skip to content

Commit

Permalink
Starting to connect active mode with disable standby.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Feb 8, 2019
1 parent 79e2206 commit c86823c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
6 changes: 5 additions & 1 deletion activity_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions activity_monitor.h
Original file line number Diff line number Diff line change
@@ -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
24 changes: 19 additions & 5 deletions audio_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c86823c

Please sign in to comment.