- Timestamp:
- Jan 26, 2014, 8:19:31 PM (11 years ago)
- 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:
- 3cc3fd8
- Parents:
- a9fd272
- Location:
- src/io
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source.c
ra9fd272 r422452b 42 42 typedef uint_t (*aubio_source_get_channels_t)(aubio_source_t * s); 43 43 typedef uint_t (*aubio_source_seek_t)(aubio_source_t * s, uint_t seek); 44 typedef uint_t (*aubio_source_close_t)(aubio_source_t * s); 44 45 typedef void (*del_aubio_source_t)(aubio_source_t * s); 45 46 … … 51 52 aubio_source_get_channels_t s_get_channels; 52 53 aubio_source_seek_t s_seek; 54 aubio_source_close_t s_close; 53 55 del_aubio_source_t s_del; 54 56 }; … … 64 66 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_avcodec_get_samplerate); 65 67 s->s_seek = (aubio_source_seek_t)(aubio_source_avcodec_seek); 68 s->s_close = (aubio_source_close_t)(aubio_source_avcodec_close); 66 69 s->s_del = (del_aubio_source_t)(del_aubio_source_avcodec); 67 70 return s; … … 76 79 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_apple_audio_get_samplerate); 77 80 s->s_seek = (aubio_source_seek_t)(aubio_source_apple_audio_seek); 81 s->s_close = (aubio_source_close_t)(aubio_source_apple_audio_close); 78 82 s->s_del = (del_aubio_source_t)(del_aubio_source_apple_audio); 79 83 return s; … … 88 92 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_sndfile_get_samplerate); 89 93 s->s_seek = (aubio_source_seek_t)(aubio_source_sndfile_seek); 94 s->s_close = (aubio_source_close_t)(aubio_source_sndfile_close); 90 95 s->s_del = (del_aubio_source_t)(del_aubio_source_sndfile); 91 96 return s; … … 100 105 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_wavread_get_samplerate); 101 106 s->s_seek = (aubio_source_seek_t)(aubio_source_wavread_seek); 107 s->s_close = (aubio_source_close_t)(aubio_source_wavread_close); 102 108 s->s_del = (del_aubio_source_t)(del_aubio_source_wavread); 103 109 return s; … … 116 122 void aubio_source_do_multi(aubio_source_t * s, fmat_t * data, uint_t * read) { 117 123 s->s_do_multi((void *)s->source, data, read); 124 } 125 126 uint_t aubio_source_close(aubio_source_t * s) { 127 return s->s_close((void *)s->source); 118 128 } 119 129 -
src/io/source.h
ra9fd272 r422452b 142 142 /** 143 143 144 close source object 145 146 \param s source object, created with ::new_aubio_source 147 148 \return 0 if sucessful, non-zero on failure 149 150 */ 151 uint_t aubio_source_close (aubio_source_t *s); 152 153 /** 154 144 155 close source and cleanup memory 145 156 -
src/io/source_apple_audio.c
ra9fd272 r422452b 258 258 { 259 259 OSStatus err = noErr; 260 if (!s || !s->audioFile) { return AUBIO_FAIL; }260 if (!s->audioFile) { return AUBIO_FAIL; } 261 261 err = ExtAudioFileDispose(s->audioFile); 262 262 s->audioFile = NULL; -
src/io/source_apple_audio.h
ra9fd272 r422452b 122 122 /** 123 123 124 close source 125 126 \param s source object, created with ::new_aubio_source_apple_audio 127 128 \return 0 if sucessful, non-zero on failure 129 130 */ 131 uint_t aubio_source_apple_audio_close(aubio_source_apple_audio_t * s); 132 133 /** 134 124 135 close source and cleanup memory 125 136 -
src/io/source_avcodec.c
ra9fd272 r422452b 391 391 } 392 392 393 void del_aubio_source_avcodec(aubio_source_avcodec_t * s){ 394 if (!s) return; 395 if (s->output != NULL) { 396 av_free(s->output); 397 } 393 uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) { 398 394 if (s->avr != NULL) { 399 395 avresample_close( s->avr ); … … 401 397 } 402 398 s->avr = NULL; 403 if (s->avFrame != NULL) {404 avcodec_free_frame( &(s->avFrame) );405 }406 s->avFrame = NULL;407 399 if (s->avCodecCtx != NULL) { 408 400 avcodec_close ( s->avCodecCtx ); … … 412 404 avformat_close_input ( &(s->avFormatCtx) ); 413 405 } 406 s->avFormatCtx = NULL; 407 return AUBIO_OK; 408 } 409 410 void del_aubio_source_avcodec(aubio_source_avcodec_t * s){ 411 if (!s) return; 412 aubio_source_avcodec_close(s); 413 if (s->output != NULL) { 414 av_free(s->output); 415 } 416 s->output = NULL; 417 if (s->avFrame != NULL) { 418 avcodec_free_frame( &(s->avFrame) ); 419 } 414 420 s->avFrame = NULL; 415 s->avFormatCtx = NULL;416 421 AUBIO_FREE(s); 417 422 } -
src/io/source_avcodec.h
ra9fd272 r422452b 121 121 /** 122 122 123 close source 124 125 \param s source object, created with ::new_aubio_source_avcodec 126 127 \return 0 if sucessful, non-zero on failure 128 129 */ 130 uint_t aubio_source_avcodec_close (aubio_source_avcodec_t *s); 131 132 /** 133 123 134 close source and cleanup memory 124 135 -
src/io/source_sndfile.c
ra9fd272 r422452b 268 268 } 269 269 270 uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) { 271 if (!s->handle) { 272 return AUBIO_FAIL; 273 if(sf_close(s->handle)) { 274 AUBIO_ERR("Error closing file %s: %s", s->path, sf_strerror (NULL)); 275 return AUBIO_FAIL; 276 } 277 return AUBIO_OK; 278 } 279 270 280 void del_aubio_source_sndfile(aubio_source_sndfile_t * s){ 271 281 if (!s) return; 272 if (sf_close(s->handle)) { 273 AUBIO_ERR("Error closing file %s: %s", s->path, sf_strerror (NULL)); 274 } 282 aubio_source_sndfile_close(s): 275 283 #ifdef HAVE_SAMPLERATE 276 284 if (s->resampler != NULL) { -
src/io/source_sndfile.h
ra9fd272 r422452b 121 121 /** 122 122 123 close source 124 125 \param s source object, created with ::new_aubio_source_sndfile 126 127 \return 0 if sucessful, non-zero on failure 128 129 */ 130 uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s); 131 132 /** 133 123 134 close source and cleanup memory 124 135 -
src/io/source_wavread.c
ra9fd272 r422452b 347 347 } 348 348 349 uint_t aubio_source_wavread_close (aubio_source_wavread_t * s) { 350 if (!s->fid || fclose(s->fid)) { 351 return AUBIO_FAIL; 352 } 353 return AUBIO_OK; 354 } 355 349 356 void del_aubio_source_wavread(aubio_source_wavread_t * s) { 350 357 if (!s) return; 351 if (s->fid) fclose(s->fid);358 aubio_source_wavread_close(s); 352 359 if (s->short_output) AUBIO_FREE(s->short_output); 353 360 if (s->output) del_fmat(s->output); -
src/io/source_wavread.h
ra9fd272 r422452b 126 126 /** 127 127 128 close source 129 130 \param s source object, created with ::new_aubio_source_wavread 131 132 \return 0 if sucessful, non-zero on failure 133 134 */ 135 uint_t aubio_source_wavread_close (aubio_source_wavread_t *s); 136 137 /** 138 128 139 close source and cleanup memory 129 140
Note: See TracChangeset
for help on using the changeset viewer.