From: Mike Brady Date: Tue, 5 Feb 2019 11:26:54 +0000 (+0000) Subject: Clean up audio help texts, add in the volume_range_hw_priority setting. X-Git-Tag: 3.3RC0~66^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=552218ab6ea149bcd2d26a3bf9e393094708481a;p=thirdparty%2Fshairport-sync.git Clean up audio help texts, add in the volume_range_hw_priority setting. --- diff --git a/audio.c b/audio.c index a2c21287..78686376 100644 --- a/audio.c +++ b/audio.c @@ -106,17 +106,17 @@ audio_output *audio_get_output(char *name) { void audio_ls_outputs(void) { audio_output **out; - printf("Available audio outputs:\n"); + printf("Available audio backends:\n"); for (out = outputs; *out; out++) printf(" %s%s\n", (*out)->name, out == outputs ? " (default)" : ""); for (out = outputs; *out; out++) { printf("\n"); if ((*out)->help) { - printf("Options for output %s:\n", (*out)->name); + printf("Settings and options for the audio backend \"%s\":\n", (*out)->name); (*out)->help(); } else { - printf("No options for output %s:\n", (*out)->name); + printf("There are no settings or options for the audio backend \"%s\".\n", (*out)->name); } } } diff --git a/audio_alsa.c b/audio_alsa.c index e54230da..2fd4497d 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -162,11 +162,10 @@ static uint64_t frame_index; static int measurement_data_is_valid; static void help(void) { - printf(" -d output-device set the output device [default*|...]\n" - " -m mixer-device set the mixer device ['output-device'*|...]\n" - " -c mixer-control set the mixer control [Master*|...]\n" - " -i mixer-index set the mixer index [0*|...]\n" - " *) default option\n"); + printf(" -d output-device set the output device, default is \"default\".\n" + " -c mixer-control set the mixer control name, default is to use no mixer.\n" + " -m mixer-device set the mixer device, default is the output device.\n" + " -i mixer-index set the mixer index, default is 0.\n"); } void set_alsa_out_dev(char *dev) { alsa_out_dev = dev; } @@ -202,7 +201,7 @@ int open_mixer() { debug(3, "Mixer Control name is \"%s\".", alsa_mix_ctrl); alsa_mix_elem = snd_mixer_find_selem(alsa_mix_handle, alsa_mix_sid); if (!alsa_mix_elem) { - debug(1, "Failed to find mixer element"); + warn("failed to find mixer control \"%s\".", alsa_mix_ctrl); response = -5; } else { response = 1; // we found a hardware mixer and successfully opened it diff --git a/audio_dummy.c b/audio_dummy.c index d8dea87f..88c63c94 100644 --- a/audio_dummy.c +++ b/audio_dummy.c @@ -54,10 +54,9 @@ static int play(__attribute__((unused)) void *buf, __attribute__((unused)) int s static void stop(void) { debug(1, "dummy audio stopped\n"); } -static void help(void) { printf(" There are no options for dummy audio.\n"); } audio_output audio_dummy = {.name = "dummy", - .help = &help, + .help = NULL, .init = &init, .deinit = &deinit, .start = &start, diff --git a/audio_pa.c b/audio_pa.c index cd321bd9..8dd38b8b 100644 --- a/audio_pa.c +++ b/audio_pa.c @@ -300,10 +300,8 @@ static void stop(void) { pa_stream_disconnect(stream); } -static void help(void) { printf(" no settings.\n"); } - audio_output audio_pa = {.name = "pa", - .help = &help, + .help = NULL, .init = &init, .deinit = &deinit, .start = &start, diff --git a/audio_pipe.c b/audio_pipe.c index 89a09a0c..e97f6034 100644 --- a/audio_pipe.c +++ b/audio_pipe.c @@ -127,7 +127,7 @@ static void deinit(void) { close(fd); } -static void help(void) { printf(" pipe takes 1 argument: the name of the FIFO to write to.\n"); } +static void help(void) { printf(" specify the pathname of the pipe to write to.\n"); } audio_output audio_pipe = {.name = "pipe", .help = &help, diff --git a/audio_stdout.c b/audio_stdout.c index 0438b1af..ea48e73d 100644 --- a/audio_stdout.c +++ b/audio_stdout.c @@ -74,10 +74,8 @@ static void deinit(void) { // don't close stdout } -static void help(void) { printf(" stdout takes no arguments\n"); } - audio_output audio_stdout = {.name = "stdout", - .help = &help, + .help = NULL, .init = &init, .deinit = &deinit, .start = &start, diff --git a/common.h b/common.h index 463e49b4..59fa72ce 100644 --- a/common.h +++ b/common.h @@ -182,7 +182,7 @@ typedef struct { // into the "active" mode. uint32_t volume_range_db; // the range, in dB, from max dB to min dB. Zero means use the mixer's // native range. - int volume_range_hw_priority; // when lowering the volume, use all the hw attenuation before using + int volume_range_hw_priority; // when extending the volume range by combining sw and hw attenuators, lowering the volume, use all the hw attenuation before using // sw attenuation enum sps_format_t output_format; enum volume_control_profile_type volume_control_profile; diff --git a/player.c b/player.c index e94e249b..8cf3df90 100644 --- a/player.c +++ b/player.c @@ -2673,7 +2673,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c // before using the hw attenuation. // one imagines that hw priority is likely to be much better // if (config.volume_range_hw_priority) { - if (1) { + if (config.volume_range_hw_priority != 0) { // hw priority if ((sw_max_db - sw_min_db) > scaled_attenuation) { software_attenuation = sw_min_db + scaled_attenuation; diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf index 031ce572..4a6ebe29 100644 --- a/scripts/shairport-sync.conf +++ b/scripts/shairport-sync.conf @@ -29,6 +29,7 @@ general = // volume_control_profile = "standard" ; // use this advanced setting to specify how the airplay volume is transferred to the mixer volume. // "standard" makes the volume change more quickly at lower volumes and slower at higher volumes. // "flat" makes the volume change at the same rate at all volumes. +// volume_range_hw_priority = "yes"; // when extending the volume range by combining the built-in software attenuator with the hardware mixer attenuator, set this to "yes" to reduce volume by using the hardware attenuator first, then the software attenuator. // 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". diff --git a/shairport.c b/shairport.c index 9ef40521..e2e7b3c4 100644 --- a/shairport.c +++ b/shairport.c @@ -62,7 +62,6 @@ #include "activity_monitor.h" #include "common.h" -#include "mdns.h" #include "rtp.h" #include "rtsp.h" @@ -96,7 +95,7 @@ #include #endif -static int shutting_down = 0; +// static int shutting_down = 0; char configuration_file_path[4096 + 1]; char actual_configuration_file_path[4096 + 1]; @@ -113,11 +112,9 @@ static void sig_shutdown(__attribute__((unused)) int foo, __attribute__((unused) static void sig_child(__attribute__((unused)) int foo, __attribute__((unused)) siginfo_t *bar, __attribute__((unused)) void *baz) { + // wait for child processes to exit pid_t pid; while ((pid = waitpid((pid_t)-1, 0, WNOHANG)) > 0) { - if (pid == mdns_pid && !shutting_down) { - die("MDNS child process died unexpectedly!"); - } } } @@ -333,6 +330,8 @@ int parse_options(int argc, char **argv) { config.fixedLatencyOffset = 11025; // this sounds like it works properly. config.diagnostic_drop_packet_fraction = 0.0; config.active_mode_timeout = 10.0; + config.volume_range_hw_priority = 1; // if combining software and hardware volume control, give the hardware priority + // i.e. when reducing volume, reduce the hw first before reducing the software. #ifdef CONFIG_METADATA_HUB config.cover_art_cache_dir = "/tmp/shairport-sync/.cache/coverart"; @@ -608,6 +607,9 @@ int parse_options(int argc, char **argv) { die("Invalid volume_control_profile choice \"%s\". It should be \"standard\" (default) " "or \"flat\""); } + + config_set_lookup_bool(config.cfg, "general.volume_control_combined_hardware_priority", &config.volume_range_hw_priority); + /* Get the interface to listen on, if specified Default is all interfaces */ /* we keep the interface name and the index */