From: Mike Brady Date: Fri, 21 Jul 2017 10:29:03 +0000 (+0200) Subject: Move common audio backend settings like buffer size and offsets to the "general"... X-Git-Tag: 3.1~10^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7864b4ecf4397f2519c1a893f7aed3f8287d9ed;p=thirdparty%2Fshairport-sync.git Move common audio backend settings like buffer size and offsets to the "general" settings stanza. Improve the resync code a little. --- diff --git a/audio.c b/audio.c index c4f6e6a7..1ba178ec 100644 --- a/audio.c +++ b/audio.c @@ -24,6 +24,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "common.h" #include "audio.h" #include "config.h" #include @@ -58,14 +59,11 @@ extern audio_output audio_stdout; #endif static audio_output *outputs[] = { -#ifdef CONFIG_SNDIO - &audio_sndio, -#endif #ifdef CONFIG_ALSA &audio_alsa, #endif -#ifdef CONFIG_PULSE - &audio_pulse, +#ifdef CONFIG_SNDIO + &audio_sndio, #endif #ifdef CONFIG_PA &audio_pa, @@ -76,14 +74,17 @@ static audio_output *outputs[] = { #ifdef CONFIG_SOUNDIO &audio_soundio, #endif -#ifdef CONFIG_DUMMY - &audio_dummy, -#endif #ifdef CONFIG_PIPE &audio_pipe, #endif #ifdef CONFIG_STDOUT &audio_stdout, +#endif +#ifdef CONFIG_DUMMY + &audio_dummy, +#endif +#ifdef CONFIG_PULSE + &audio_pulse, #endif NULL}; @@ -114,3 +115,78 @@ void audio_ls_outputs(void) { (*out)->help(); } } + +void parse_general_audio_options(void) { + /* this must be called after the output device has been initialised, so that the default values are set before any options are chosen */ + int value; + double dvalue; + if (config.cfg != NULL) { + + /* Get the desired buffer size setting (deprecated). */ + if (config_lookup_int(config.cfg, "general.audio_backend_buffer_desired_length", &value)) { + if ((value < 0) || (value > 66150)) { + inform("The setting general.audio_backend_buffer_desired_length is deprecated. " + "Use alsa.audio_backend_buffer_desired_length_in_seconds instead."); + die("Invalid audio_backend_buffer_desired_length value: \"%d\". It " + "should be between 0 and " + "66150, default is %d", + value,(int)(config.audio_backend_buffer_desired_length*44100)); + } else { + inform("The setting general.audio_backend_buffer_desired_length is deprecated. " + "Use general.audio_backend_buffer_desired_length_in_seconds instead."); + config.audio_backend_buffer_desired_length = 1.0 * value / 44100; + } + } + + /* Get the desired buffer size setting in seconds. */ + if (config_lookup_float(config.cfg, "general.audio_backend_buffer_desired_length_in_seconds", + &dvalue)) { + if ((dvalue < 0) || (dvalue > 1.5)) { + die("Invalid audio_backend_buffer_desired_length_in_seconds value: \"%f\". It " + "should be between 0 and " + "1.5, default is %.3f seconds", + dvalue,config.audio_backend_buffer_desired_length); + } else { + config.audio_backend_buffer_desired_length = dvalue; + } + } + + /* Get the latency offset (deprecated). */ + if (config_lookup_int(config.cfg, "general.audio_backend_latency_offset", &value)) { + if ((value < -66150) || (value > 66150)) { + inform("The setting general.audio_backend_latency_offset is deprecated. " + "Use general.audio_backend_latency_offset_in_seconds instead."); + die("Invalid audio_backend_latency_offset value: \"%d\". It " + "should be between -66150 and +66150, default is 0", + value); + } else { + inform("The setting general.audio_backend_latency_offset is deprecated. " + "Use general.audio_backend_latency_offset_in_seconds instead."); + config.audio_backend_latency_offset = 1.0 * value / 44100; + } + } + + /* Get the latency offset in seconds. */ + if (config_lookup_float(config.cfg, "general.audio_backend_latency_offset_in_seconds", &dvalue)) { + if ((dvalue < -1.0) || (dvalue > 1.5)) { + die("Invalid audio_backend_latency_offset_in_seconds \"%f\". It " + "should be between -1.0 and +1.5, default is 0 seconds", + dvalue); + } else { + config.audio_backend_latency_offset = dvalue; + } + } + + /* Get the desired length of the silent lead-in. */ + if (config_lookup_float(config.cfg, "general.audio_backend_silent_lead_in_time", + &dvalue)) { + if ((dvalue < 0.05) || (dvalue > 4)) { + die("Invalid 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; + } + } + } +} diff --git a/audio.h b/audio.h index 31fa1069..e0defc55 100644 --- a/audio.h +++ b/audio.h @@ -47,5 +47,6 @@ typedef struct { audio_output *audio_get_output(char *name); void audio_ls_outputs(void); +void parse_general_audio_options(void); #endif //_AUDIO_H diff --git a/audio_alsa.c b/audio_alsa.c index f70ce9a6..fa2ef13e 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -158,90 +158,22 @@ static int init(int argc, char **argv) { int value; double dvalue; + // set up default values first set_period_size_request = 0; set_buffer_size_request = 0; config.alsa_use_playback_switch_for_mute = 1; config.audio_backend_latency_offset = 0; - config.audio_backend_buffer_desired_length = 0.15; + config.audio_backend_buffer_desired_length = 0.15; // get settings from settings file first, allow them to be overridden by // command line options + + // do the "general" audio options. Note, these options are in the "general" stanza! + parse_general_audio_options(); if (config.cfg != NULL) { - /* Get the desired buffer size setting. */ - if (config_lookup_int(config.cfg, "alsa.audio_backend_buffer_desired_length", &value)) { - if ((value < 0) || (value > 66150)) { - inform("The setting alsa.audio_backend_buffer_desired_length is deprecated. " - "Use alsa.audio_backend_buffer_desired_length_in_seconds instead."); - pthread_mutex_unlock(&alsa_mutex); - die("Invalid alsa audio backend buffer desired length \"%d\". It " - "should be between 0 and " - "66150, default is 6615", - value); - } else { - inform("The setting alsa.audio_backend_buffer_desired_length is deprecated. " - "Use alsa.audio_backend_buffer_desired_length_in_seconds instead."); - config.audio_backend_buffer_desired_length = 1.0 * value / 44100; - } - } - - /* 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)) { - if ((dvalue < 0) || (dvalue > 1.5)) { - pthread_mutex_unlock(&alsa_mutex); - die("Invalid alsa 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, "alsa.audio_backend_latency_offset", &value)) { - if ((value < -66150) || (value > 66150)) { - inform("The setting alsa.audio_backend_latency_offset is deprecated. " - "Use alsa.audio_backend_latency_offset_in_seconds instead."); - pthread_mutex_unlock(&alsa_mutex); - die("Invalid alsa audio backend buffer latency offset \"%d\". It " - "should be between -66150 and +66150, default is 0", - value); - } else { - inform("The setting alsa.audio_backend_latency_offset is deprecated. " - "Use alsa.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, "alsa.audio_backend_latency_offset_in_seconds", &dvalue)) { - if ((dvalue < -1.0) || (dvalue > 1.5)) { - pthread_mutex_unlock(&alsa_mutex); - die("Invalid alsa 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; - } - } - /* Get the Output Device Name. */ if (config_lookup_string(config.cfg, "alsa.output_device", &str)) { alsa_out_dev = (char *)str; diff --git a/audio_ao.c b/audio_ao.c index 03aac687..49ff4efe 100644 --- a/audio_ao.c +++ b/audio_ao.c @@ -47,81 +47,17 @@ static int init(int argc, char **argv) { ao_initialize(); int driver = ao_default_driver_id(); ao_option *ao_opts = NULL; + + // set up default values first config.audio_backend_buffer_desired_length = 1.0; config.audio_backend_latency_offset = 0; - // 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)) { - inform("The setting ao.audio_backend_buffer_desired_length is deprecated. " - "Use ao.audio_backend_buffer_desired_length_in_seconds instead."); - die("Invalid ao audio backend buffer desired length \"%d\". It " - "should be between 0 and " - "66150, default is 6615", - value); - } else { - inform("The setting ao.audio_backend_buffer_desired_length is deprecated. " - "Use ao.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, "ao.audio_backend_buffer_desired_length_in_seconds", - &dvalue)) { - if ((dvalue < 0) || (dvalue > 1.5)) { - die("Invalid ao 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, "ao.audio_backend_latency_offset", &value)) { - if ((value < -66150) || (value > 66150)) { - inform("The setting ao.audio_backend_latency_offset is deprecated. " - "Use ao.audio_backend_latency_offset_in_seconds instead."); - die("Invalid ao audio backend buffer latency offset \"%d\". It " - "should be between -66150 and +66150, default is 0", - value); - } else { - inform("The setting ao.audio_backend_latency_offset is deprecated. " - "Use ao.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, "ao.audio_backend_latency_offset_in_seconds", &dvalue)) { - if ((dvalue < -1.0) || (dvalue > 1.5)) { - die("Invalid ao 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; - } - } - } + // get settings from settings file first, allow them to be overridden by + // command line options + + // do the "general" audio options. Note, these options are in the "general" stanza! + parse_general_audio_options(); optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour argv--; // so we shift the arguments to satisfy getopt() diff --git a/audio_pa.c b/audio_pa.c index 5a75e6b8..451d4d78 100644 --- a/audio_pa.c +++ b/audio_pa.c @@ -42,51 +42,18 @@ void stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userdata); static int init(int argc, char **argv) { - // default values + // set up default values first config.audio_backend_buffer_desired_length = 0.35; config.audio_backend_latency_offset = 0; - - // get settings from settings file first, allow them to be overridden by - // command line options + + // get settings from settings file + + // do the "general" audio options. Note, these options are in the "general" stanza! + parse_general_audio_options(); + // now the specific options 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", - &dvalue)) { - if ((dvalue < 0) || (dvalue > 1.5)) { - die("Invalid pa audio_backend_buffer_desired_length_in_seconds \"%f\". It " - "should be between 0 and " - "1.5, default is 0.35 seconds", - dvalue); - } else { - config.audio_backend_buffer_desired_length = dvalue; - } - } - - /* Get the latency offset. */ - if (config_lookup_float(config.cfg, "pa.audio_backend_latency_offset_in_seconds", &dvalue)) { - if ((dvalue < -1.0) || (dvalue > 1.5)) { - die("Invalid pa audio_backend_latency_offset_in_seconds \"%f\". It " - "should be between -1.0 and +1.5, default is 0 seconds", - dvalue); - } else { - config.audio_backend_latency_offset = dvalue; - } - } /* Get the Application Name. */ if (config_lookup_string(config.cfg, "pa.application_name", &str)) { diff --git a/audio_pipe.c b/audio_pipe.c index a27ca65f..7ab4969d 100644 --- a/audio_pipe.c +++ b/audio_pipe.c @@ -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"); diff --git a/audio_sndio.c b/audio_sndio.c index 3434324f..d8b80ad1 100644 --- a/audio_sndio.c +++ b/audio_sndio.c @@ -59,6 +59,7 @@ static size_t played; static size_t written; int64_t time_of_last_onmove_cb; int at_least_one_onmove_cb_seen; +struct sio_par par; struct sndio_formats { const char *name; @@ -84,10 +85,10 @@ static void help() { } static int init(int argc, char **argv) { - struct sio_par par; int i, found, opt, round, rate, bufsz; const char *devname, *tmp; + // set up default values first sio_initpar(&par); par.rate = 44100; @@ -98,6 +99,16 @@ static int init(int argc, char **argv) { par.sig = 1; devname = SIO_DEVANY; + config.audio_backend_buffer_desired_length = 1.0; + config.audio_backend_latency_offset = 0; + + // get settings from settings file + + // do the "general" audio options. Note, these options are in the "general" stanza! + parse_general_audio_options(); + + // get the specific settings + if (config.cfg != NULL) { if (!config_lookup_string(config.cfg, "sndio.device", &devname)) devname = SIO_DEVANY; @@ -243,7 +254,7 @@ static int delay(long *_delay) { // calculate the difference in time between now and when the last callback occoured, // and use it to estimate the frames that would have been output uint64_t time_difference = get_absolute_time_in_fp() - time_of_last_onmove_cb; - uint64_t frame_difference = time_difference * 44100; + uint64_t frame_difference = time_difference * par.rate; uint64_t frame_difference_big_integer = frame_difference>>32; estimated_extra_frames_output = frame_difference_big_integer; // debug(1,"Frames played to last cb: %d, estimated to current time: %d.",played,estimated_extra_frames_output); diff --git a/audio_soundio.c b/audio_soundio.c index 17f09562..7376f70b 100644 --- a/audio_soundio.c +++ b/audio_soundio.c @@ -84,8 +84,17 @@ static void underflow_callback(struct SoundIoOutStream *outstream) { static int init(int argc, char **argv) { int err; + config.audio_backend_buffer_desired_length = 2.0; + config.audio_backend_latency_offset = 0; + // get settings from settings file + + // do the "general" audio options. Note, these options are in the "general" stanza! + parse_general_audio_options(); + + // get the specific settings + soundio = soundio_create(); if (!soundio) { debug(0, "out of memory\n"); diff --git a/audio_stdout.c b/audio_stdout.c index 33d3f339..66b9b3bd 100644 --- a/audio_stdout.c +++ b/audio_stdout.c @@ -56,82 +56,13 @@ static void stop(void) { } static int init(int argc, char **argv) { - const char *str; - int value; - double dvalue; - + // set up default values first config.audio_backend_buffer_desired_length = 1.0; 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)) { - inform("The setting audio_backend_buffer_desired_length is deprecated. " - "Use audio_backend_buffer_desired_length_in_seconds instead."); - die("Invalid stdout audio backend buffer desired length \"%d\". It " - "should be between 0 and " - "66150, default is 6615", - value); - } else { - inform("The stdout.setting audio_backend_buffer_desired_length is deprecated. " - "Use stdout.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, "stdout.audio_backend_buffer_desired_length_in_seconds", - &dvalue)) { - if ((dvalue < 0) || (dvalue > 1.5)) { - die("Invalid stdout 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, "stdout.audio_backend_latency_offset", &value)) { - if ((value < -66150) || (value > 66150)) { - inform("The setting stdout.audio_backend_latency_offset is deprecated. " - "Use stdout.audio_backend_latency_offset_in_seconds instead."); - die("Invalid stdout audio backend buffer latency offset \"%d\". It " - "should be between -66150 and +66150, default is 0", - value); - } else { - inform("The setting stdout.audio_backend_latency_offset is deprecated. " - "Use stdout.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, "stdout.audio_backend_latency_offset_in_seconds", - &dvalue)) { - if ((dvalue < -1.0) || (dvalue > 1.5)) { - die("Invalid stdout 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; - } - } - } + + // get settings from settings file + // do the "general" audio options. Note, these options are in the "general" stanza! + parse_general_audio_options(); return 0; } diff --git a/player.c b/player.c index 21bff732..a01d9de5 100644 --- a/player.c +++ b/player.c @@ -1491,7 +1491,7 @@ static void *player_thread_func(void *arg) { "depth"); } if (conn->fix_volume != 0x10000) { - debug(1, "Dithering will be enabled the output volume is being altered in software"); + debug(1, "Dithering will be enabled becasuse the output volume is being altered in software"); } // we need an intermediate "transition" buffer @@ -1807,14 +1807,14 @@ static void *player_thread_func(void *arg) { size_t filler_length = config.resyncthreshold * config.output_rate; // number of samples if ((sync_error > 0) && (sync_error > filler_length)) { - // debug(1, "Large positive sync error: %lld. Dropping the frame.", sync_error); + debug(1, "Large positive sync error: %lld. Dropping the frame.", sync_error); } else if ((sync_error < 0) && ((-sync_error) > filler_length)) { - // debug(1, "Large negative sync error: %lld. Inserting silence.", sync_error); + debug(1, "Large negative sync error: %lld. Inserting silence.", sync_error); char *long_silence = malloc(conn->output_bytes_per_frame * (-sync_error)); if (long_silence == NULL) die("Failed to allocate memory for a long_silence buffer."); - memset(long_silence, 0, conn->output_bytes_per_frame * filler_length); - config.output->play((short *)long_silence, filler_length); + memset(long_silence, 0, conn->output_bytes_per_frame * (-sync_error)); + config.output->play((short *)long_silence, (-sync_error)); free(long_silence); } } else { diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf index 5b8a73a7..3fcbac06 100644 --- a/scripts/shairport-sync.conf +++ b/scripts/shairport-sync.conf @@ -23,6 +23,7 @@ general = // drift_tolerance_in_seconds = 0.002; // allow a timing error of this number of seconds of drift away from exact synchronisation before attempting to correct it // resync_threshold_in_seconds = 0.050; // a synchronisation error greater than this number of seconds will cause resynchronisation; 0 disables it // log_verbosity = 0; // "0" means no debug verbosity, "3" is most verbose. + // ignore_volume_control = "no"; // set this to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to. // volume_range_db = 60 ; // use this advanced setting to set the range, in dB, you want between the maximum volume and the minimum volume. Range is 30 to 150 dB. Leave it commented out to use mixer's native range. // volume_max_db = 0.0 ; // use this advanced setting, which must have a decimal point in it, to set the maximum volume, in dB, you wish to use. @@ -31,11 +32,16 @@ general = // run_this_when_volume_is_set = "/full/path/to/application/and/args"; // Run the specified application whenever the volume control is set or changed. // The desired AirPlay volume is appended to the end of the command line – leave a space if you want it treated as an extra argument. // AirPlay volume goes from 0 to -30 and -144 means "mute". + // regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp". // playback_mode = "stereo"; // This can be "stereo", "mono", "reverse stereo", "both left" or "both right". Default is "stereo". // alac_decoder = "hammerton"; // This can be "hammerton" or "apple". This advanced setting allows you to choose // the original Shairport decoder by David Hammerton or the Apple Lossless Audio Codec (ALAC) decoder written by Apple. // interface = "name"; // Use this advanced setting to specify the interface on which Shairport Sync should provide its service. Leave it commented out to get the default, which is to select the interface(s) automatically. + +// audio_backend_latency_offset_in_seconds = 0.0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. +// audio_backend_buffer_desired_length_in_seconds = 0.15; // If set too small, buffer underflow occurs on low-powered machines. Too long and the response time to volume changes becomes annoying. Default is 0.15 seconds in the alsa backend, 0.35 seconds in the pa backend and 1.0 seconds otherwise. +// audio_backend_silent_lead_in_time = 2.0; // Use this optional advanced setting, between 0.050 and 4.0 seconds, to set the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. }; @@ -100,9 +106,6 @@ alsa = // mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this. // output_rate = 44100; // can be 44100, 88200, 176400 or 352800, but the device must have the capability. // output_format = "S16"; // can be "U8", "S8", "S16", "S24", "S24_3LE", "S24_3BE" or "S32", but the device must have the capability. Except where stated using (*LE or *BE), endianness matches that of the processor. -// audio_backend_latency_offset_in_seconds = 0.0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. -// audio_backend_buffer_desired_length_in_seconds = 0.15; // If set too small, buffer underflow occurs on low-powered machines. Too long and the response times with software mixer become annoying. -// audio_backend_silent_lead_in_time = 2.0; // Use this optional advanced setting, between 0.050 and 4.0 seconds, to set the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. // disable_synchronization = "no"; // Set to "yes" to disable synchronization. Default is "no". // period_size = ; // Use this optional advanced setting to set the alsa period size near to this value // buffer_size = ; // Use this optional advanced setting to set the alsa buffer size near to this value @@ -110,7 +113,7 @@ alsa = // mute_using_playback_switch = "yes"; // Use this optional advanced setting to control whether the snd_mixer_selem_set_playback_switch_all call can be used for muting. Default is yes. }; -// These are parameters for the "sndio" audio back end. All are optional. +// Parameters for the "sndio" audio back end. All are optional. sndio = { // device = "snd/0"; // the name of the output device @@ -120,39 +123,21 @@ sndio = // bufsz = ; // set the buffer size near to this value }; -// These are parameters for the "pa" PulseAudio backend. +// Parameters for the "pa" PulseAudio backend. pa = { // application_name = "Shairport Sync"; //Set this to the name that should appear in the Sounds "Applications" tab when Shairport Sync is active. -// audio_backend_latency_offset_in_seconds = 0.0; // Set this offset in seconds to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. -// audio_backend_buffer_desired_length_in_seconds = 0.35; // Having started to send audio at the right time, send all subsequent audio this much ahead of time, creating a buffer this length. -// audio_backend_silent_lead_in_time = 2.0; // Use this optional advanced setting, between 0.050 and 4.0 seconds, to set the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. }; -// These are parameters for the "pipe" audio back end, a back end that directs raw CD-style audio output to a pipe. No interpolation is done. +// Parameters for the "pipe" audio back end, a back end that directs raw CD-style audio output to a pipe. No interpolation is done. pipe = { // name = "/path/to/pipe"; // there is no default pipe name for the output -// audio_backend_latency_offset_in_seconds = 0.0; // Set this offset in seconds to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. -// audio_backend_buffer_desired_length_in_seconds = 1.0; // Having started to send audio at the right time, send all subsequent audio this much ahead of time, creating a buffer this length. -// audio_backend_silent_lead_in_time = 2.0; // Use this optional advanced setting, between 0.050 and 4.0 seconds, to set the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. }; -// These are parameters for the "stdout" audio back end, a back end that directs raw CD-style audio output to stdout. No interpolation is done. -stdout = -{ -// audio_backend_latency_offset_in_seconds = 0.0; // Set this offset in seconds to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. -// audio_backend_buffer_desired_length_in_seconds = 1.0; // Having started to send audio at the right time, send all subsequent audio this much ahead of time, creating a buffer this length. -// audio_backend_silent_lead_in_time = 2.0; // Use this optional advanced setting, between 0.050 and 4.0 seconds, to set the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. -}; +// These are no configuration file parameters for the "stdout" audio back end. No interpolation is done. -// These are parameters for the "ao" audio back end. No interpolation is done. -ao = -{ -// audio_backend_latency_offset_in_seconds = 0.0; // Set this offset in seconds to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. -// audio_backend_buffer_desired_length_in_seconds = 1.0; // Having started to send audio at the right time, send all subsequent audio this much ahead of time, creating a buffer this length. -// audio_backend_silent_lead_in_time = 2.0; // Use this optional advanced setting, between 0.050 and 4.0 seconds, to set the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. -}; +// These are no configuration file parameters for the "ao" audio back end. No interpolation is done. // Static latency settings are deprecated and the settings have been removed.