shithub: choc

Download patch

ref: 15b8e6e1e47e4f733f862c16a5c18a3485bd22d4
parent: 9b75e50ff9e34dfab85247862cdf416ab486f3ab
author: Fabian Greffrath <[email protected]>
date: Mon Oct 24 11:30:18 EDT 2016

i_sdlsound.c: fix compilation with libsamplerate 0.1.9

This new version has const-corrected the data_in field, fixes #788

--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -404,6 +404,7 @@
                                    int length)
 {
     SRC_DATA src_data;
+    float *data_in;
     uint32_t i, abuf_index=0, clipped=0;
 //    uint32_t alen;
     int retn;
@@ -412,7 +413,8 @@
     Mix_Chunk *chunk;
 
     src_data.input_frames = length;
-    src_data.data_in = malloc(length * sizeof(float));
+    data_in = malloc(length * sizeof(float));
+    src_data.data_in = data_in;
     src_data.src_ratio = (double)mixer_freq / samplerate;
 
     // We include some extra space here in case of rounding-up.
@@ -428,7 +430,7 @@
         // Unclear whether 128 should be interpreted as "zero" or whether a
         // symmetrical range should be assumed.  The following assumes a
         // symmetrical range.
-        src_data.data_in[i] = data[i] / 127.5 - 1;
+        data_in[i] = data[i] / 127.5 - 1;
     }
 
     // Do the sound conversion
@@ -497,7 +499,7 @@
         expanded[abuf_index++] = cvtval_i;
     }
 
-    free(src_data.data_in);
+    free(data_in);
     free(src_data.data_out);
 
     if (clipped > 0)