Ignore:
Timestamp:
Dec 20, 2018, 5:30:33 PM (6 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/timestretch, fix/ffmpeg5, master
Children:
f5a97ed
Parents:
14a5b9a
Message:

[sink_wavwrite] factorise in aubio_sink_wavwrite_write_frames, use AUBIO_STRERROR

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_wavwrite.c

    r14a5b9a ra2b7187  
    239239}
    240240
     241static
     242void aubio_sink_wavwrite_write_frames(aubio_sink_wavwrite_t *s, uint_t write)
     243{
     244  uint_t written_frames = 0;
     245
     246  written_frames = fwrite(s->scratch_data, 2 * s->channels, write, s->fid);
     247
     248  if (written_frames != write) {
     249    char errorstr[256];
     250    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
     251    AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, but only %d"
     252        " could be written (%s)\n", write, s->path, written_frames, errorstr);
     253  }
     254  s->total_frames_written += written_frames;
     255}
    241256
    242257void aubio_sink_wavwrite_do(aubio_sink_wavwrite_t *s, fvec_t * write_data, uint_t write){
    243   uint_t c = 0, i = 0, written_frames = 0;
     258  uint_t c = 0, i = 0;
    244259  uint_t length = aubio_sink_validate_input_length("sink_wavwrite", s->path,
    245260      s->max_size, write_data->length, write);
     
    250265    }
    251266  }
    252   written_frames = fwrite(s->scratch_data, 2, length * s->channels, s->fid);
    253 
    254   if (written_frames != write) {
    255     AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, "
    256         "but only %d could be written\n", write, s->path, written_frames);
    257   }
    258   s->total_frames_written += written_frames;
    259   return;
     267
     268  aubio_sink_wavwrite_write_frames(s, length);
    260269}
    261270
    262271void aubio_sink_wavwrite_do_multi(aubio_sink_wavwrite_t *s, fmat_t * write_data, uint_t write){
    263   uint_t c = 0, i = 0, written_frames = 0;
     272  uint_t c = 0, i = 0;
    264273
    265274  uint_t channels = aubio_sink_validate_input_channels("sink_wavwrite", s->path,
     
    273282    }
    274283  }
    275   written_frames = fwrite(s->scratch_data, 2, length * s->channels, s->fid);
    276 
    277   if (written_frames != write * s->channels) {
    278     AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, "
    279         "but only %d could be written\n", write, s->path, written_frames / s->channels);
    280   }
    281   s->total_frames_written += written_frames;
    282   return;
     284
     285  aubio_sink_wavwrite_write_frames(s, length);
    283286}
    284287
Note: See TracChangeset for help on using the changeset viewer.