]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Remove the AUTO bit-depth setting. It's a hack and needs more consideration.
authorMike Brady <mikebrady@eircom.net>
Thu, 28 Feb 2019 14:21:05 +0000 (14:21 +0000)
committerMike Brady <mikebrady@eircom.net>
Thu, 28 Feb 2019 14:21:05 +0000 (14:21 +0000)
audio_alsa.c
common.c
common.h
player.c
shairport.c

index 5896b4317fc6c3781ea4208c201184bb65faac03..2312d83991694f55fda5dd3609b95d29ee825038 100644 (file)
@@ -339,82 +339,50 @@ int actual_open_alsa_device(void) {
     return ret;
   }
   
-  
-  if (sample_format == SPS_FORMAT_AUTO) {
-  
-    struct alsa_formats {
-      snd_pcm_format_t alsa_sound_format;
-      enum sps_format_t sps_sound_format;
-      int frame_size;
-      char * description;
-    };
-  
-    struct alsa_formats formats[] = {{SND_PCM_FORMAT_S32,SPS_FORMAT_S32,8,"S32"},
-                                     {SND_PCM_FORMAT_S24,SPS_FORMAT_S24,8,"S24"},
-                                     {SND_PCM_FORMAT_S24_3LE,SPS_FORMAT_S24_3LE,6,"S24_LE"},
-                                     {SND_PCM_FORMAT_S24_3BE,SPS_FORMAT_S24_3BE,6,"S24_BE"},
-                                     {SND_PCM_FORMAT_S16,SPS_FORMAT_S16,4,"S16"}};
-                                     
-    int acceptable_format_found = 0;
-    unsigned int i = 0;
-    while((!acceptable_format_found) && (i < sizeof(formats) / sizeof(formats[0]))) {
-      if (snd_pcm_hw_params_set_format(alsa_handle, alsa_params, formats[i].alsa_sound_format) == 0) {
-        acceptable_format_found = 1;
-        frame_size = formats[i].frame_size;
-        config.output_format = formats[i].sps_sound_format;
-        debug(1,"alsa: output format automatically chosen to be \"%s\".",formats[i].description);
-      } else {
-        i++;
-      }
-    }
-    if (!acceptable_format_found) {
-      die("Can't find a suitable automatic output format setting.");
-    }
-  } else {
-    snd_pcm_format_t sf;
-    switch (sample_format) {
-    case SPS_FORMAT_S8:
-      sf = SND_PCM_FORMAT_S8;
-      frame_size = 2;
-      break;
-    case SPS_FORMAT_U8:
-      sf = SND_PCM_FORMAT_U8;
-      frame_size = 2;
-      break;
-    case SPS_FORMAT_S16:
-      sf = SND_PCM_FORMAT_S16;
-      frame_size = 4;
-      break;
-    case SPS_FORMAT_S24:
-      sf = SND_PCM_FORMAT_S24;
-      frame_size = 8;
-      break;
-    case SPS_FORMAT_S24_3LE:
-      sf = SND_PCM_FORMAT_S24_3LE;
-      frame_size = 6;
-      break;
-    case SPS_FORMAT_S24_3BE:
-      sf = SND_PCM_FORMAT_S24_3BE;
-      frame_size = 6;
-      break;
-    case SPS_FORMAT_S32:
-      sf = SND_PCM_FORMAT_S32;
-      frame_size = 8;
-      break;
-    default:
-      sf = SND_PCM_FORMAT_S16; // this is just to quieten a compiler warning
-      frame_size = 4;
-      debug(1, "Unsupported output format at audio_alsa.c");
-      return -EINVAL;
-    }
+  snd_pcm_format_t sf;
+  switch (sample_format) {
+  case SPS_FORMAT_S8:
+    sf = SND_PCM_FORMAT_S8;
+    frame_size = 2;
+    break;
+  case SPS_FORMAT_U8:
+    sf = SND_PCM_FORMAT_U8;
+    frame_size = 2;
+    break;
+  case SPS_FORMAT_S16:
+    sf = SND_PCM_FORMAT_S16;
+    frame_size = 4;
+    break;
+  case SPS_FORMAT_S24:
+    sf = SND_PCM_FORMAT_S24;
+    frame_size = 8;
+    break;
+  case SPS_FORMAT_S24_3LE:
+    sf = SND_PCM_FORMAT_S24_3LE;
+    frame_size = 6;
+    break;
+  case SPS_FORMAT_S24_3BE:
+    sf = SND_PCM_FORMAT_S24_3BE;
+    frame_size = 6;
+    break;
+  case SPS_FORMAT_S32:
+    sf = SND_PCM_FORMAT_S32;
+    frame_size = 8;
+    break;
+  default:
+    sf = SND_PCM_FORMAT_S16; // this is just to quieten a compiler warning
+    frame_size = 4;
+    debug(1, "Unsupported output format at audio_alsa.c");
+    return -EINVAL;
+  }
 
-    ret = snd_pcm_hw_params_set_format(alsa_handle, alsa_params, sf);
-    if (ret < 0) {
-      warn("audio_alsa: Sample format %d not available for device \"%s\": %s", sample_format,
-           alsa_out_dev, snd_strerror(ret));
-      return ret;
-    }
+  ret = snd_pcm_hw_params_set_format(alsa_handle, alsa_params, sf);
+  if (ret < 0) {
+    warn("audio_alsa: Sample format %d not available for device \"%s\": %s", sample_format,
+         alsa_out_dev, snd_strerror(ret));
+    return ret;
   }
+  
 
   if (set_period_size_request != 0) {
     debug(1, "Attempting to set the period size");
@@ -934,10 +902,8 @@ static int init(int argc, char **argv) {
         config.output_format = SPS_FORMAT_U8;
       else if (strcasecmp(str, "S8") == 0)
         config.output_format = SPS_FORMAT_S8;
-      else if (strcasecmp(str, "AUTOMATIC") == 0)
-        config.output_format = SPS_FORMAT_AUTO;
       else {
-        warn("Invalid output format \"%s\". It should be \"Automatic\", \"U8\", \"S8\", "
+        warn("Invalid output format \"%s\". It should be \"U8\", \"S8\", "
              "\"S16\", \"S24\", "
              "\"S24_3LE\", \"S24_3BE\" or "
              "\"S32\". It is set to \"S16\".",
index ec70e2fed31db6e19eb34b95b0147cea9759b787..4db41149270a9fbb6b6bddd80bed56ba06fde5eb 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1391,8 +1391,6 @@ int64_t generate_zero_frames(char *outp, size_t number_of_frames, enum sps_forma
     case SPS_FORMAT_UNKNOWN:
       die("Unexpected SPS_FORMAT_UNKNOWN while calculating dither mask.");
       break;
-    case SPS_FORMAT_AUTO:
-      die("Unexpected SPS_FORMAT_AUTO while calculating dither mask.");
     }
     dither_mask -= 1;
     // int64_t r = r64i();
index 6f92abbe37311d14efd2abc4c44a9211dadaf729..9bc849e1e85be53b8fee2244386ae1afd9d4b314 100644 (file)
--- a/common.h
+++ b/common.h
@@ -80,7 +80,6 @@ enum sps_format_t {
   SPS_FORMAT_S24_3LE,
   SPS_FORMAT_S24_3BE,
   SPS_FORMAT_S32,
-  SPS_FORMAT_AUTO,
 } sps_format_t;
 
 typedef struct {
index 881a735955bb7b2e34660810ead04af013d47a37..485166eece097bf0b8c03c35f550d46bf2ea6336 100644 (file)
--- a/player.c
+++ b/player.c
@@ -683,9 +683,6 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t
     case SPS_FORMAT_UNKNOWN:
       die("Unexpected SPS_FORMAT_UNKNOWN while calculating dither mask.");
       break;
-    case SPS_FORMAT_AUTO:
-      die("Unexpected SPS_FORMAT_AUTO while calculating dither mask.");
-      break;
     }
     dither_mask -= 1;
     // int64_t r = r64i();
@@ -763,9 +760,6 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t
   case SPS_FORMAT_UNKNOWN:
     die("Unexpected SPS_FORMAT_UNKNOWN while outputting samples");
     break;
-  case SPS_FORMAT_AUTO:
-    die("Unexpected SPS_FORMAT_AUTO while outputting samples");
-    break;
   }
 
   *outp += result;
@@ -1653,9 +1647,6 @@ void *player_thread_func(void *arg) {
   case SPS_FORMAT_UNKNOWN:
     die("Unknown format choosing output bit depth");
     break;
-  case SPS_FORMAT_AUTO:
-    die("Unexpected SPS_FORMAT_AUTO while outputting samples");
-    break;
   }
 
   debug(3, "Output bit depth is %d.", output_bit_depth);
index 8f87e1c9d5674c48b7009e8e0cb98f4875061b58..3a0502cac469f254d4edfcf66020a5923fa8a042 100644 (file)
@@ -1577,7 +1577,7 @@ int main(int argc, char **argv) {
   debug(1, "use_mmap_if_available is %d.", config.no_mmap ? 0 : 1);
   debug(1, "output_rate is %d.", config.output_rate);
   debug(1,
-        "output_format is %d (0-unknown, 1-S8, 2-U8, 3-S16, 4-S24, 5-S24_3LE, 6-S24_3BE, 7-S32, 8-Automatic).",
+        "output_format is %d (0-unknown, 1-S8, 2-U8, 3-S16, 4-S24, 5-S24_3LE, 6-S24_3BE, 7-S32).",
         config.output_format);
   debug(1, "audio backend desired buffer length is %f seconds.",
         config.audio_backend_buffer_desired_length);