]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
enable specification of specific formats and/or speeds to turn off automatic format...
authorMike Brady <mikebrady@eircom.net>
Wed, 29 May 2019 15:00:47 +0000 (16:00 +0100)
committerMike Brady <mikebrady@eircom.net>
Wed, 29 May 2019 15:00:47 +0000 (16:00 +0100)
audio_alsa.c
scripts/shairport-sync.conf

index cd692f1d56447b331d6129f077bd5370733c7116..a6de218c5e3176e8eaa4f8e6d43f7fe36f3a5a57 100644 (file)
@@ -1037,6 +1037,8 @@ static int init(int argc, char **argv) {
 
     /* Get the output format, using the same names as aplay does*/
     if (config_lookup_string(config.cfg, "alsa.output_format", &str)) {
+       int temp_output_format_auto_requested = config.output_format_auto_requested;
+       config.output_format_auto_requested = 0; // assume a valid format will be given.
       if (strcasecmp(str, "S16") == 0)
         config.output_format = SPS_FORMAT_S16;
       else if (strcasecmp(str, "S16_LE") == 0)
@@ -1066,11 +1068,12 @@ static int init(int argc, char **argv) {
       else if (strcasecmp(str, "auto") == 0)
         config.output_format_auto_requested = 1;
       else {
-        warn("Invalid output format \"%s\". It should be \"U8\", \"S8\", "
+       config.output_format_auto_requested = temp_output_format_auto_requested; //format was invalid; recall the original setting
+        warn("Invalid output format \"%s\". It should be \"auto\", \"U8\", \"S8\", "
              "\"S16\", \"S24\", \"S24_LE\", \"S24_BE\", "
              "\"S24_3LE\", \"S24_3BE\" or "
-             "\"S32\", \"S32_LE\", \"S32_BE\". It is set to \"%s\".",
-             sps_format_description_string(config.output_format));
+             "\"S32\", \"S32_LE\", \"S32_BE\". It remains set to \"%s\".", str,
+             config.output_format_auto_requested == 1 ? "auto" : sps_format_description_string(config.output_format));
       }
     }
 
@@ -1078,25 +1081,35 @@ static int init(int argc, char **argv) {
                        if (strcasecmp(str, "auto") == 0) {
                                config.output_rate_auto_requested = 1;
                        } else {
-                               /* Get the output rate, which must be a multiple of 44,100*/
-                               if (config_lookup_int(config.cfg, "alsa.output_rate", &value)) {
-                                       debug(1, "alsa output rate is %d frames per second", value);
-                                       switch (value) {
-                                       case 44100:
-                                       case 88200:
-                                       case 176400:
-                                       case 352800:
-                                               config.output_rate = value;
-                                               break;
-                                       default:
-                                               warn("Invalid output rate \"%d\". It should be \"auto\" or a multiple of 44,100 up "
-                                                                "to 352,800. It is "
-                                                                "set to %d.",
-                                                                value,config.output_rate);
-                                       }
-                               }
+                               if (config.output_rate_auto_requested == 1)
+                                       warn("Invalid output rate \"%s\". It should be \"auto\", 44100, 88200, 176400 or 352800. "
+                                                "It remains set to \"auto\". Note: numbers should not be placed in quotes.", str);
+                               else
+                                       warn("Invalid output rate \"%s\". It should be \"auto\", 44100, 88200, 176400 or 352800. "
+                                                "It remains set to %d. Note: numbers should not be placed in quotes.", str, config.output_rate);
                        }
-    }
+               }
+               
+               /* Get the output rate, which must be a multiple of 44,100*/
+               if (config_lookup_int(config.cfg, "alsa.output_rate", &value)) {
+                       debug(1, "alsa output rate is %d frames per second", value);
+                       switch (value) {
+                       case 44100:
+                       case 88200:
+                       case 176400:
+                       case 352800:
+                               config.output_rate = value;
+                               config.output_rate_auto_requested = 0;
+                               break;
+                       default:
+                               if (config.output_rate_auto_requested == 1)
+                                       warn("Invalid output rate \"%d\". It should be \"auto\", 44100, 88200, 176400 or 352800. "
+                                                "It remains set to \"auto\".",value);
+                               else
+                                       warn("Invalid output rate \"%d\".It should be \"auto\", 44100, 88200, 176400 or 352800. "
+                                                "It remains set to %d.", value, config.output_rate);
+                       }
+               }
 
     /* Get the use_mmap_if_available setting. */
     if (config_lookup_string(config.cfg, "alsa.use_mmap_if_available", &str)) {
@@ -1107,7 +1120,7 @@ static int init(int argc, char **argv) {
       else {
         warn("Invalid use_mmap_if_available option choice \"%s\". It should be "
              "\"yes\" or \"no\". "
-             "It is set to \"yes\".");
+             "It remains set to \"yes\".");
         config.no_mmap = 0;
       }
     }
@@ -1163,7 +1176,7 @@ static int init(int argc, char **argv) {
       else {
         warn("Invalid disable_standby_mode option choice \"%s\". It should be "
              "\"always\", \"auto\" or \"never\". "
-             "It is set to \"never\".");
+             "It remains set to \"never\".");
       }
     }
 
@@ -1179,7 +1192,7 @@ static int init(int argc, char **argv) {
       else {
         warn("Invalid use_precision_timing option choice \"%s\". It should be "
              "\"yes\", \"auto\" or \"no\". "
-             "It is set to \"auto\".");
+             "It remains set to \"%s\".", config.use_precision_timing == YNA_NO ? "no" : config.use_precision_timing == YNA_AUTO ? "auto" : "yes");
       }
     }
 
index cd342d8e17a75fd5ea70faa13ff21bb4e1a9611f..a17d6337b067826badbdb5551ba8206af30fae95 100644 (file)
@@ -84,7 +84,7 @@ alsa =
 //     mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software.
 //     mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this.
 //     output_rate = "auto"; // can be "auto", 44100, 88200, 176400 or 352800, but the device must have the capability.
-//     output_format = "auto"; // can be "auto", ""U8", "S8", "S16", "S16_LE", "S16_BE", "S24", "S24_LE", "S24_BE", "S24_3LE", "S24_3BE", "S32", "S32_LE" or "S32_BE" but the device must have the capability. Except where stated using (*LE or *BE), endianness matches that of the processor.
+//     output_format = "auto"; // can be "auto", "U8", "S8", "S16", "S16_LE", "S16_BE", "S24", "S24_LE", "S24_BE", "S24_3LE", "S24_3BE", "S32", "S32_LE" or "S32_BE" but the device must have the capability. Except where stated using (*LE or *BE), endianness matches that of the processor.
 //     disable_synchronization = "no"; // Set to "yes" to disable synchronization. Default is "no".
 //     period_size = <number>; // Use this optional advanced setting to set the alsa period size near to this value
 //     buffer_size = <number>; // Use this optional advanced setting to set the alsa buffer size near to this value
@@ -200,8 +200,8 @@ mqtt =
 //     enabled = "no"; // set this to yes to enable the mqtt-metadata-service
 //     hostname = "iot.eclipse.org"; // Hostname of the MQTT Broker
 //     port = 1883; // Port on the MQTT Broker to connect to
-//     username = NULL; //set this to a string with your username, to enable username authentication
-//     password = NULL; //set this to a string with your password, to enable username & password authentication
+//     username = NULL; //set this to a string to your username in order to enable username authentication
+//     password = NULL; //set this to a string you your password in order to enable username & password authentication
 //     capath = NULL; //set this to the folder with the CA-Certificates to be accepted for the server certificate. If not set, TLS is not used
 //     cafile = NULL; //this may be used as an (exclusive) alternative to capath with a single file for all ca-certificates
 //     certfile = NULL; //set this to a string to a user certificate to enable MQTT Client certificates. keyfile must also be set!
@@ -216,7 +216,7 @@ mqtt =
 //     Available commands are "command", "beginff", "beginrew", "mutetoggle", "nextitem", "previtem", "pause", "playpause", "play", "stop", "playresume", "shuffle_songs", "volumedown", "volumeup"
 }
 
-// Diagnostic settings. These are for diagnostic and debugging only. Normally you sould leave them commented out
+// Diagnostic settings. These are for diagnostic and debugging only. Normally you should leave them commented out
 diagnostics =
 {
 //     disable_resend_requests = "no"; // set this to yes to stop Shairport Sync from requesting the retransmission of missing packets. Default is "no".