Skip to content

Commit

Permalink
Add code to read audio_backend_silent_lead_in_time settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Jul 6, 2017
1 parent aced2a7 commit d428585
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
13 changes: 13 additions & 0 deletions audio_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ static int init(int argc, char **argv) {
}
}

/* Get the desired length of the period of silence before the audio starts. */
if (config_lookup_float(config.cfg, "alsa.audio_backend_silent_lead_in_time",
&dvalue)) {
if ((dvalue < 0.05) || (dvalue > 4)) {
pthread_mutex_unlock(&alsa_mutex);
die("Invalid alsa audio_backend_silent_lead_in_time \"%f\". It "
"must be between 0.050 and 4.0 seconds. Omit setting to use the default value, which is approximately the latency specified by the source (typically 2 seconds). A value greater than the latency is ignored.",
dvalue);
} else {
config.audio_backend_silent_lead_in_time = dvalue;
}
}

/* Get the desired buffer size setting. */
if (config_lookup_float(config.cfg, "alsa.audio_backend_buffer_desired_length_in_seconds",
&dvalue)) {
Expand Down
13 changes: 13 additions & 0 deletions audio_ao.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ static int init(int argc, char **argv) {
// get settings from settings file first, allow them to be overridden by command line options

if (config.cfg != NULL) {
/* Get the desired length of the period of silence before the audio starts. */
if (config_lookup_float(config.cfg, "ao.audio_backend_silent_lead_in_time",
&dvalue)) {
if ((dvalue < 0.05) || (dvalue > 4)) {
pthread_mutex_unlock(&alsa_mutex);
die("Invalid ao audio_backend_silent_lead_in_time \"%f\". It "
"must be between 0.050 and 4.0 seconds. Omit setting to use the default value, which is approximately the latency specified by the source (typically 2 seconds). A value greater than the latency is ignored.",
dvalue);
} else {
config.audio_backend_silent_lead_in_time = dvalue;
}
}

/* Get the desired buffer size setting. */
if (config_lookup_int(config.cfg, "ao.audio_backend_buffer_desired_length", &value)) {
if ((value < 0) || (value > 66150)) {
Expand Down
11 changes: 11 additions & 0 deletions audio_pa.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ static int init(int argc, char **argv) {
if (config.cfg != NULL) {
const char *str;
double dvalue;
/* Get the desired length of the period of silence before the audio starts. */
if (config_lookup_float(config.cfg, "pa.audio_backend_silent_lead_in_time",
&dvalue)) {
if ((dvalue < 0.05) || (dvalue > 4)) {
die("Invalid pa audio_backend_silent_lead_in_time \"%f\". It "
"must be between 0.050 and 4.0 seconds. Omit setting to use the default value, which is approximately the latency specified by the source (typically 2 seconds). A value greater than the latency is ignored.",
dvalue);
} else {
config.audio_backend_silent_lead_in_time = dvalue;
}
}

/* Get the desired buffer size setting. */
if (config_lookup_float(config.cfg, "pa.audio_backend_buffer_desired_length_in_seconds",
Expand Down
12 changes: 12 additions & 0 deletions audio_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ static int init(int argc, char **argv) {
if (config_lookup_string(config.cfg, "pipe.name", &str)) {
pipename = (char *)str;
}

/* Get the desired length of the period of silence before the audio starts. */
if (config_lookup_float(config.cfg, "pipe.audio_backend_silent_lead_in_time",
&dvalue)) {
if ((dvalue < 0.05) || (dvalue > 4)) {
die("Invalid pipe audio_backend_silent_lead_in_time \"%f\". It "
"must be between 0.050 and 4.0 seconds. Omit setting to use the default value, which is approximately the latency specified by the source (typically 2 seconds). A value greater than the latency is ignored.",
dvalue);
} else {
config.audio_backend_silent_lead_in_time = dvalue;
}
}

if ((pipename) && (strcasecmp(pipename, "STDOUT") == 0))
die("Can't use \"pipe\" backend for STDOUT. Use the \"stdout\" backend instead.");
Expand Down
12 changes: 12 additions & 0 deletions audio_stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ static int init(int argc, char **argv) {
config.audio_backend_latency_offset = 0;

if (config.cfg != NULL) {
/* Get the desired length of the period of silence before the audio starts. */
if (config_lookup_float(config.cfg, "stdout.audio_backend_silent_lead_in_time",
&dvalue)) {
if ((dvalue < 0.05) || (dvalue > 4)) {
die("Invalid stdout audio_backend_silent_lead_in_time \"%f\". It "
"must be between 0.050 and 4.0 seconds. Omit setting to use the default value, which is approximately the latency specified by the source (typically 2 seconds). A value greater than the latency is ignored.",
dvalue);
} else {
config.audio_backend_silent_lead_in_time = dvalue;
}
}

/* Get the desired buffer size setting. */
if (config_lookup_int(config.cfg, "stdout.audio_backend_buffer_desired_length", &value)) {
if ((value < 0) || (value > 66150)) {
Expand Down
1 change: 1 addition & 0 deletions shairport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ int main(int argc, char **argv) {
debug(1, "audio backend desired buffer length is %f seconds.",
config.audio_backend_buffer_desired_length);
debug(1, "audio backend latency offset is %f seconds.", config.audio_backend_latency_offset);
debug(1, "audio backend silence lead-in time is %f seconds. The value -1.0 means use the default.", config.audio_backend_silent_lead_in_time);
debug(1, "volume range in dB (zero means use the range specified by the mixer): %u.",
config.volume_range_db);
debug(1, "zeroconf regtype is \"%s\".", config.regtype);
Expand Down

0 comments on commit d428585

Please sign in to comment.