Commit 003a16980c469bf5a0ded03c6179bdcbc6c601ba

Ryan C. Gordon 2020-10-06T11:07:50

wav: Make sure the data size is a multiple of blockalign, not an exact match. I _think_ this is a right thing to do; it fixes a .wav file I have here that has blockalign==2 when channels==2 and bitspersample==16, which otherwise would fail.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 0359016..0eec7bf 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1334,7 +1334,8 @@ PCM_Init(WaveFile *file, size_t datalength)
     /* It wouldn't be that hard to support more exotic block sizes, but
      * the most common formats should do for now.
      */
-    if (format->blockalign * 8 != format->channels * format->bitspersample) {
+    /* Make sure we're a multiple of the blockalign, at least. */
+    if ((format->channels * format->bitspersample) % (format->blockalign * 8)) {
         return SDL_SetError("Unsupported block alignment");
     }