shithub: aubio

Download patch

ref: 8ba8bbeafd0abc42e7edf8735bf73180d92b59b3
parent: 6e8aa746e7b5b3d6158dc785a8d7e68ff75da869
parent: fa5d8add56f38a464e156e98e0c23e4f2cc4b9c5
author: Paul Brossier <piem@piem.org>
date: Wed Sep 21 11:47:48 EDT 2016

Merge branch 'master' into pitchshift

--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -60,7 +60,7 @@
   - "python setup.py build"
   - "pip install ."
   - "python python\\demos\\demo_create_test_sounds.py"
-  - "nose2"
+  - "nose2 --verbose"
   # clean up
   - waf distclean
   # build libaubio
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -98,7 +98,8 @@
 
   if (s->handle == NULL) {
     /* show libsndfile err msg */
-    AUBIO_ERR("source_sndfile: Failed opening %s: %s\n", s->path, sf_strerror (NULL));
+    AUBIO_ERR("source_sndfile: Failed opening %s (%s)\n", s->path,
+        sf_strerror (NULL));
     goto beach;
   }
 
--- a/src/io/source_wavread.c
+++ b/src/io/source_wavread.c
@@ -135,9 +135,9 @@
       goto beach;
     }
     bytes_read += bytes_junk;
-    bytes_expected += bytes_junk;
+    bytes_expected += bytes_junk + 4;
     // now really read the fmt chunk
-    fread(buf, 1, 4, s->fid);
+    bytes_read += fread(buf, 1, 4, s->fid);
     buf[4] = '\0';
   }
 
@@ -229,9 +229,23 @@
   // Subchunk2ID
   bytes_read += fread(buf, 1, 4, s->fid);
   buf[4] = '\0';
-  if ( strcmp((const char *)buf, "data") != 0 ) {
-    AUBIO_ERR("source_wavread: data RIFF header not found in %s\n", s->path);
-    goto beach;
+  while ( strcmp((const char *)buf, "data") != 0 ) {
+    if (feof(s->fid) || ferror(s->fid)) {
+      AUBIO_ERR("source_wavread: no data RIFF header found in %s\n", s->path);
+      goto beach;
+    }
+    bytes_junk = fread(buf, 1, 4, s->fid);
+    buf[4] = '\0';
+    bytes_junk += read_little_endian(buf, 4);
+    if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) {
+      AUBIO_ERR("source_wavread: could not seek past unknown chunk in %s (%s)\n",
+          s->path, strerror(errno));
+      goto beach;
+    }
+    bytes_read += bytes_junk;
+    bytes_expected += bytes_junk+ 4;
+    bytes_read += fread(buf, 1, 4, s->fid);
+    buf[4] = '\0';
   }
 
   // Subchunk2Size
--