Move common audio backend settings like buffer size and offsets to the "general" settings stanza. Improve the resync code a little.

This commit is contained in:
Mike Brady
2017-07-21 12:29:03 +02:00
parent d810d43048
commit b7864b4ecf
11 changed files with 153 additions and 365 deletions
+6 -66
View File
@@ -86,8 +86,13 @@ static int init(int argc, char **argv) {
int value;
double dvalue;
// set up default values first
config.audio_backend_buffer_desired_length = 1.0;
config.audio_backend_latency_offset = 0;
// do the "general" audio options. Note, these options are in the "general" stanza!
parse_general_audio_options();
if (config.cfg != NULL) {
/* Get the Output Pipename. */
@@ -96,76 +101,11 @@ static int init(int argc, char **argv) {
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.");
/* Get the desired buffer size setting. */
if (config_lookup_int(config.cfg, "pipe.audio_backend_buffer_desired_length", &value)) {
if ((value < 0) || (value > 66150)) {
inform("The setting pipe.audio_backend_buffer_desired_length is deprecated. "
"Use pipe.audio_backend_buffer_desired_length_in_seconds instead.");
die("Invalid pipe audio backend buffer desired length \"%d\". It "
"should be between 0 and "
"66150, default is 6615",
value);
} else {
inform("The setting pipe.audio_backend_buffer_desired_length is deprecated. "
"Use pipe.audio_backend_buffer_desired_length_in_seconds instead.");
config.audio_backend_buffer_desired_length = 1.0 * value / 44100;
}
}
/* Get the desired buffer size setting. */
if (config_lookup_float(config.cfg, "pipe.audio_backend_buffer_desired_length_in_seconds",
&dvalue)) {
if ((dvalue < 0) || (dvalue > 1.5)) {
die("Invalid pipe audio backend buffer desired time \"%f\". It "
"should be between 0 and "
"1.5, default is 0.15 seconds",
dvalue);
} else {
config.audio_backend_buffer_desired_length = dvalue;
}
}
/* Get the latency offset. */
if (config_lookup_int(config.cfg, "pipe.audio_backend_latency_offset", &value)) {
if ((value < -66150) || (value > 66150)) {
inform("The setting pipe.audio_backend_latency_offset is deprecated. "
"Use pipe.audio_backend_latency_offset_in_seconds instead.");
die("Invalid pipe audio backend buffer latency offset \"%d\". It "
"should be between -66150 and +66150, default is 0",
value);
} else {
inform("The setting pipe.audio_backend_latency_offset is deprecated. "
"Use pipe.audio_backend_latency_offset_in_seconds instead.");
config.audio_backend_latency_offset = 1.0 * value / 44100;
}
}
/* Get the latency offset. */
if (config_lookup_float(config.cfg, "pipe.audio_backend_latency_offset_in_seconds", &dvalue)) {
if ((dvalue < -1.0) || (dvalue > 1.5)) {
die("Invalid pipe audio backend buffer latency offset time \"%f\". It "
"should be between -1.0 and +1.5, default is 0 seconds",
dvalue);
} else {
config.audio_backend_latency_offset = dvalue;
}
}
}
if ((pipename == NULL) && (argc != 1))
die("bad or missing argument(s) to pipe");