]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Fix some warnings from clang on FreeBSD. One was significant -- the randarray stuff...
authorMike Brady <mikebrady@eircom.net>
Sun, 16 Apr 2017 15:52:43 +0000 (16:52 +0100)
committerMike Brady <mikebrady@eircom.net>
Sun, 16 Apr 2017 15:52:43 +0000 (16:52 +0100)
audio_alsa.c
common.c
player.c

index f843d0d92c6ff05487389fa6921d66c6c46bd833..43542ec5732bda14542910628a3d698b60957efe 100644 (file)
@@ -66,7 +66,7 @@ audio_output audio_alsa = {.name = "alsa",
 static pthread_mutex_t alsa_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static unsigned int desired_sample_rate;
-static snd_pcm_format_t sample_format;
+static enum sps_format_t sample_format;
 
 static snd_pcm_t *alsa_handle = NULL;
 static snd_pcm_hw_params_t *alsa_params = NULL;
@@ -517,6 +517,8 @@ int open_alsa_device(void) {
   case SPS_FORMAT_S32:
     sf = SND_PCM_FORMAT_S32;
     break;
+  default:
+    die("Unsupported output format at audio_alsa.c");
   }
   ret = snd_pcm_hw_params_set_format(alsa_handle, alsa_params, sf);
   if (ret < 0) {
index 48df934acb59ffc0687691d7f8c719148e95d6d7..5c10c9182cb268dbfa2374e613b1bd4276a16f87 100644 (file)
--- a/common.c
+++ b/common.c
@@ -755,11 +755,13 @@ void ranarrayinit() {
 
 uint64_t ranarrayval() {
   uint64_t v = ranarray[ranarraynext];
-  ranarraynext = (ranarraynext++) % ranarraylength;
+  ranarraynext++;
+  ranarraynext = ranarraynext % ranarraylength;
+  return v;
 }
 
 void r64arrayinit() { ranarrayinit(); }
 
 uint64_t ranarray64u() { return (ranarrayval()); }
 
-int64_t ranarray64i() { return (ranarrayval(&rx) >> 1); }
+int64_t ranarray64i() { return (ranarrayval() >> 1); }
index 6012d01abd8a04c61c72bb5456891945b0632d56..9f57e1c449879f2ca4dcf39ea127292ebc71c810 100644 (file)
--- a/player.c
+++ b/player.c
@@ -599,6 +599,8 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t
     case SPS_FORMAT_U8:
       dither_mask = (int64_t)1 << (64 + 1 - 8);
       break;
+    case SPS_FORMAT_UNKNOWN:
+      die("Unexpected SPS_FORMAT_UNKNOWN while calculating dither mask.");
     }
     dither_mask -= 1;
     // int64_t r = r64i();
@@ -673,6 +675,8 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t
     *op = hyper_sample;
     result = 1;
     break;
+  case SPS_FORMAT_UNKNOWN:
+    die("Unexpected SPS_FORMAT_UNKNOWN while outputting samples");
   }
 
   *outp += result;
@@ -1321,7 +1325,6 @@ static void *player_thread_func(void *arg) {
                                                    // rate, multiply it by the frame ratio.
                                                    // but, on some occasions, more than one frame could be added
 
-  conn->output_bytes_per_frame = 4;
   switch (config.output_format) {
   case SPS_FORMAT_S24_3LE:
   case SPS_FORMAT_S24_3BE:
@@ -1333,6 +1336,8 @@ static void *player_thread_func(void *arg) {
   case SPS_FORMAT_S32:
     conn->output_bytes_per_frame = 8;
     break;
+  default:
+    conn->output_bytes_per_frame = 4;
   }
   
   debug(1, "Output frame bytes is %d.", conn->output_bytes_per_frame);
@@ -1415,6 +1420,8 @@ static void *player_thread_func(void *arg) {
   case SPS_FORMAT_S32:
     output_bit_depth = 32;
     break;
+  case SPS_FORMAT_UNKNOWN:
+    die("Unknown format choosing output bit depth");
   }
 
   debug(1, "Output bit depth is %d.", output_bit_depth);
@@ -1570,6 +1577,8 @@ static void *player_thread_func(void *arg) {
                 case ST_right_only:
                   ls = rs;
                   break;
+                case ST_stereo:
+                  break; // nothing extra to do
                 }
 
                 // here, replicate the samples if you're upsampling
@@ -1817,14 +1826,14 @@ static void *player_thread_func(void *arg) {
                     stuff_buffer_basic_32((int32_t *)tbuf, inbuflength, config.output_format,
                                           outbuf, amount_to_stuff, enable_dither, conn);
               break;
-#ifdef HAVE_LIBSOXR
             case ST_soxr:
+#ifdef HAVE_LIBSOXR
               //                if (amount_to_stuff) debug(1,"Soxr stuff...");
                 play_samples = stuff_buffer_soxr_32((int32_t *)tbuf, (int32_t *)sbuf, inbuflength,
                                                     config.output_format, outbuf, amount_to_stuff,
                                                     enable_dither,conn);
-              break;
 #endif
+              break;
             }
 
             /*