Commit b2f6c4c1bd8b2c7399a7332f3a7e863fd922920d

Sam Lantinga 2016-12-19T11:15:53

Fixed bus error when converting 16-bit to float for non-integral-multiple sample rates

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 7262d0b..283163f 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1191,8 +1191,10 @@ open_audio_device(const char *devname, int iscapture,
             return 0;
         }
         if (device->convert.needed) {
-            device->convert.len = (int) (((double) device->spec.size) /
+            device->convert.len = (int) (((double) device->spec.samples) /
                                          device->convert.len_ratio);
+            device->convert.len *= SDL_AUDIO_BITSIZE(device->spec.format) / 8;
+            device->convert.len *= device->spec.channels;
 
             device->convert.buf =
                 (Uint8 *) SDL_malloc(device->convert.len *