Changeset fa5d8ad for src/io


Ignore:
Timestamp:
Sep 21, 2016, 3:24:06 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
88c89e3, 8ba8bbe
Parents:
a27576b
Message:

src/io/source_wavread.c: skip chunks until data is found, or abort

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_wavread.c

    ra27576b rfa5d8ad  
    230230  bytes_read += fread(buf, 1, 4, s->fid);
    231231  buf[4] = '\0';
    232   if ( strcmp((const char *)buf, "data") != 0 ) {
    233     AUBIO_ERR("source_wavread: data RIFF header not found in %s\n", s->path);
    234     goto beach;
     232  while ( strcmp((const char *)buf, "data") != 0 ) {
     233    if (feof(s->fid) || ferror(s->fid)) {
     234      AUBIO_ERR("source_wavread: no data RIFF header found in %s\n", s->path);
     235      goto beach;
     236    }
     237    bytes_junk = fread(buf, 1, 4, s->fid);
     238    buf[4] = '\0';
     239    bytes_junk += read_little_endian(buf, 4);
     240    if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) {
     241      AUBIO_ERR("source_wavread: could not seek past unknown chunk in %s (%s)\n",
     242          s->path, strerror(errno));
     243      goto beach;
     244    }
     245    bytes_read += bytes_junk;
     246    bytes_expected += bytes_junk+ 4;
     247    bytes_read += fread(buf, 1, 4, s->fid);
     248    buf[4] = '\0';
    235249  }
    236250
Note: See TracChangeset for help on using the changeset viewer.