From 0997de6caff56e16e0d7be0eb9cb1ac3aae2b2ed Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Wed, 14 Jun 2017 23:11:42 -0400 Subject: [PATCH] port from Pd Vanilla: aiff (and maybe wav) file reading bugfix: odd-sized chunks are padded up to even number of bytes commit a567e4398d14901840f24ac82ecfc79306e22903 --- pd/src/d_soundfile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c index 0cf6de4c2..6c7148842 100644 --- a/pd/src/d_soundfile.c +++ b/pd/src/d_soundfile.c @@ -113,7 +113,7 @@ typedef struct _wavechunk /* ... and the last two items */ #define WAV_INT 1 #define WAV_FLOAT 3 -/* the AIFF header. I'm assuming AIFC is compatible but don't really know +/* the cd lib header. I'm assuming AIFC is compatible but don't really know that. */ typedef struct _datachunk @@ -292,7 +292,8 @@ int open_soundfile_via_fd(int fd, int headersize, { long chunksize = swap4(((t_wavechunk *)buf)->wc_size, swap), seekto = headersize + chunksize + 8, seekout; - + if (seekto & 1) /* pad up to even number of bytes */ + seekto++; if (!strncmp(((t_wavechunk *)buf)->wc_id, "fmt ", 4)) { long commblockonset = headersize + 8; @@ -344,6 +345,8 @@ int open_soundfile_via_fd(int fd, int headersize, { long chunksize = swap4(((t_datachunk *)buf)->dc_size, swap), seekto = headersize + chunksize + 8, seekout; + if (seekto & 1) /* pad up to even number of bytes */ + seekto++; /* post("chunk %c %c %c %c seek %d", ((t_datachunk *)buf)->dc_id[0], ((t_datachunk *)buf)->dc_id[1], -- GitLab