- Timestamp:
- Mar 31, 2019, 11:12:40 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
- Children:
- 76b6dd3
- Parents:
- 08246ee (diff), f55630c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/io
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink.c
r08246ee r1dfe409 216 216 217 217 void del_aubio_sink(aubio_sink_t * s) { 218 AUBIO_ASSERT(s);218 //AUBIO_ASSERT(s); 219 219 if (s && s->s_del && s->sink) 220 220 s->s_del((void *)s->sink); -
src/io/sink_wavwrite.c
r08246ee r1dfe409 28 28 #include "io/sink_wavwrite.h" 29 29 #include "io/ioutils.h" 30 31 #include <errno.h>32 30 33 31 #define MAX_SIZE 4096 … … 168 166 s->fid = fopen((const char *)s->path, "wb"); 169 167 if (!s->fid) { 170 char errorstr[256]; 171 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 172 AUBIO_ERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr); 168 AUBIO_STRERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr); 173 169 goto beach; 174 170 } … … 216 212 217 213 // fwrite(*, *, 1, s->fid) was called 13 times, check success 218 if (written != 13 ) {219 char errorstr[256];220 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));221 AUBIO_WRN("sink_wavwrite: writing header to %s failed, expected %d"222 " write but got only %d (%s)\n", s->path, 13, written, errorstr);214 if (written != 13 || fflush(s->fid)) { 215 AUBIO_STRERR("sink_wavwrite: writing header to %s failed" 216 " (wrote %d/%d, %s)\n", s->path, written, 13, errorstr); 217 fclose(s->fid); 218 s->fid = NULL; 223 219 return AUBIO_FAIL; 224 220 } … … 247 243 248 244 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" 245 AUBIO_STRERR("sink_wavwrite: trying to write %d frames to %s, but only %d" 252 246 " could be written (%s)\n", write, s->path, written_frames, errorstr); 253 247 } … … 298 292 written += fwrite(write_little_endian(data_size, buf, 4), 4, 1, s->fid); 299 293 if (written != 2 || err != 0) { 300 char errorstr[256]; 301 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 302 AUBIO_WRN("sink_wavwrite: updating header of %s failed, expected %d" 294 AUBIO_STRERR("sink_wavwrite: updating header of %s failed, expected %d" 303 295 " write but got only %d (%s)\n", s->path, 2, written, errorstr); 304 296 } 305 297 // close file 306 298 if (fclose(s->fid)) { 307 char errorstr[256]; 308 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 309 AUBIO_ERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr); 299 AUBIO_STRERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr); 310 300 } 311 301 s->fid = NULL; -
src/io/source.c
r08246ee r1dfe409 139 139 140 140 void del_aubio_source(aubio_source_t * s) { 141 AUBIO_ASSERT(s);141 //AUBIO_ASSERT(s); 142 142 if (s && s->s_del && s->source) 143 143 s->s_del((void *)s->source); -
src/io/source_avcodec.c
r08246ee r1dfe409 31 31 #endif 32 32 #include <libavutil/opt.h> 33 #include <stdlib.h>34 33 35 34 // determine whether we use libavformat from ffmpeg or from libav … … 121 120 uint_t samplerate, uint_t hop_size) { 122 121 aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t); 123 AVFormatContext *avFormatCtx = s->avFormatCtx;124 AVCodecContext *avCodecCtx = s->avCodecCtx;125 AVFrame *avFrame = s->avFrame;122 AVFormatContext *avFormatCtx = NULL; 123 AVCodecContext *avCodecCtx = NULL; 124 AVFrame *avFrame = NULL; 126 125 sint_t selected_stream = -1; 127 126 #if FF_API_LAVF_AVCTX … … 465 464 (const uint8_t **)avFrame->data, in_samples); 466 465 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 467 if (out_samples < =0) {468 AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n",469 s->path );466 if (out_samples < 0) { 467 AUBIO_WRN("source_avcodec: error while resampling %s (%d)\n", 468 s->path, out_samples); 470 469 goto beach; 471 470 } … … 474 473 475 474 beach: 476 s->avFormatCtx = avFormatCtx;477 s->avCodecCtx = avCodecCtx;478 s->avFrame = avFrame;479 #if defined(HAVE_AVRESAMPLE) || defined(HAVE_SWRESAMPLE)480 s->avr = avr;481 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */482 s->output = output;483 484 475 av_packet_unref(&avPacket); 485 476 } … … 629 620 #ifdef HAVE_AVRESAMPLE 630 621 avresample_close( s->avr ); 622 av_free ( s->avr ); 631 623 #elif defined(HAVE_SWRESAMPLE) 632 624 swr_close ( s->avr ); 633 #endif 634 av_free ( s->avr ); 625 swr_free ( &s->avr ); 626 #endif 635 627 } 636 628 s->avr = NULL; -
src/io/source_sndfile.c
r08246ee r1dfe409 175 175 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, 176 176 s->scratch_size); 177 uint_t read_length = read_samples / s->input_channels; 178 179 /* where to store de-interleaved data */ 180 smpl_t *ptr_data; 181 177 182 if (!s->handle) { 178 183 AUBIO_ERR("source_sndfile: could not read from %s (file was closed)\n", … … 182 187 } 183 188 184 uint_t read_length = read_samples / s->input_channels;185 186 /* where to store de-interleaved data */187 smpl_t *ptr_data;188 189 #ifdef HAVE_SAMPLERATE 189 190 if (s->ratio != 1) { … … 226 227 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, 227 228 s->scratch_size); 229 uint_t read_length = read_samples / s->input_channels; 230 231 /* where to store de-interleaved data */ 232 smpl_t **ptr_data; 233 228 234 if (!s->handle) { 229 235 AUBIO_ERR("source_sndfile: could not read from %s (file was closed)\n", … … 233 239 } 234 240 235 uint_t read_length = read_samples / s->input_channels;236 237 /* where to store de-interleaved data */238 smpl_t **ptr_data;239 241 #ifdef HAVE_SAMPLERATE 240 242 if (s->ratio != 1) { -
src/io/source_wavread.c
r08246ee r1dfe409 28 28 #include "source_wavread.h" 29 29 30 #include <errno.h>31 32 30 #define AUBIO_WAVREAD_BUFSIZE 1024 33 31 34 #define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)32 //#define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05) 35 33 36 34 struct _aubio_source_wavread_t { … … 101 99 s->fid = fopen((const char *)path, "rb"); 102 100 if (!s->fid) { 103 AUBIO_ ERR("source_wavread: Failed opening %s (System error: %s)\n", s->path, strerror(errno));101 AUBIO_STRERR("source_wavread: Failed opening %s (%s)\n", s->path, errorstr); 104 102 goto beach; 105 103 } … … 134 132 bytes_junk += read_little_endian(buf, 4); 135 133 if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) { 136 AUBIO_ ERR("source_wavread: Failed opening %s (could not seek past JUNK Chunk: %s)\n",137 s->path, strerror(errno));134 AUBIO_STRERR("source_wavread: Failed opening %s (could not seek past JUNK Chunk: %s)\n", 135 s->path, errorstr); 138 136 goto beach; 139 137 } … … 262 260 bytes_junk += read_little_endian(buf, 4); 263 261 if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) { 264 AUBIO_ ERR("source_wavread: could not seek past unknown chunk in %s (%s)\n",265 s->path, strerror(errno));262 AUBIO_STRERR("source_wavread: could not seek past unknown chunk in %s (%s)\n", 263 s->path, errorstr); 266 264 goto beach; 267 265 } … … 443 441 ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET); 444 442 if (ret != 0) { 445 AUBIO_ ERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, strerror(errno));443 AUBIO_STRERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, errorstr); 446 444 return AUBIO_FAIL; 447 445 } … … 464 462 } 465 463 if (fclose(s->fid)) { 466 AUBIO_ ERR("source_wavread: could not close %s (%s)\n", s->path, strerror(errno));464 AUBIO_STRERR("source_wavread: could not close %s (%s)\n", s->path, errorstr); 467 465 return AUBIO_FAIL; 468 466 }
Note: See TracChangeset
for help on using the changeset viewer.