Changeset a9fd272
- Timestamp:
- Jan 26, 2014, 8:16:59 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:
- 422452b
- Parents:
- 082c88b
- Location:
- src/io
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink.c
r082c88b ra9fd272 39 39 typedef uint_t (*aubio_sink_get_channels_t)(aubio_sink_t * s); 40 40 #endif 41 typedef uint_t (*aubio_sink_close_t)(aubio_sink_t * s); 41 42 typedef void (*del_aubio_sink_t)(aubio_sink_t * s); 42 43 … … 49 50 aubio_sink_get_channels_t s_get_channels; 50 51 #endif 52 aubio_sink_close_t s_close; 51 53 del_aubio_sink_t s_del; 52 54 }; … … 58 60 if (s->sink) { 59 61 s->s_do = (aubio_sink_do_t)(aubio_sink_apple_audio_do); 62 s->s_close = (aubio_sink_close_t)(aubio_sink_apple_audio_close); 60 63 s->s_del = (del_aubio_sink_t)(del_aubio_sink_apple_audio); 61 64 return s; … … 66 69 if (s->sink) { 67 70 s->s_do = (aubio_sink_do_t)(aubio_sink_sndfile_do); 71 s->s_close = (aubio_sink_close_t)(aubio_sink_sndfile_close); 68 72 s->s_del = (del_aubio_sink_t)(del_aubio_sink_sndfile); 69 73 return s; … … 74 78 if (s->sink) { 75 79 s->s_do = (aubio_sink_do_t)(aubio_sink_wavwrite_do); 80 s->s_close = (aubio_sink_close_t)(aubio_sink_wavwrite_close); 76 81 s->s_del = (del_aubio_sink_t)(del_aubio_sink_wavwrite); 77 82 return s; 78 83 } 79 84 #endif /* HAVE_WAVWRITE */ 80 AUBIO_ERROR("sink: failed creating aubio sink with %s\n", uri); 85 AUBIO_ERROR("sink: failed creating %s with samplerate %dHz\n", 86 uri, samplerate); 81 87 AUBIO_FREE(s); 82 88 return NULL; … … 87 93 } 88 94 95 uint_t aubio_sink_close(aubio_sink_t *s) { 96 return s->s_close((void *)s->sink); 97 } 98 89 99 void del_aubio_sink(aubio_sink_t * s) { 90 100 if (!s) return; -
src/io/sink.h
r082c88b ra9fd272 64 64 /** 65 65 66 close sink 67 68 \param s sink object, created with ::new_aubio_sink 69 70 \return 0 on success, non-zero on failure 71 72 */ 73 uint_t aubio_sink_close(aubio_sink_t * s); 74 75 /** 76 66 77 close sink and cleanup memory 67 78 68 \param s s ource object, created with ::new_aubio_source79 \param s sink object, created with ::new_aubio_sink 69 80 70 81 */ -
src/io/sink_apple_audio.c
r082c88b ra9fd272 142 142 } 143 143 144 void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) {144 uint_t aubio_sink_apple_audio_close(aubio_sink_apple_audio_t * s) { 145 145 OSStatus err = noErr; 146 if (!s || !s->audioFile) { 147 AUBIO_ERR("sink_apple_audio: failed erasing\n"); 148 return; 146 if (!s->audioFile) { 147 return AUBIO_FAIL; 149 148 } 150 149 err = ExtAudioFileDispose(s->audioFile); … … 156 155 } 157 156 s->audioFile = NULL; 157 return err; 158 } 159 160 void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) { 161 if (s->audioFile) aubio_sink_apple_audio_close (s); 158 162 freeAudioBufferList(&s->bufferList); 159 163 AUBIO_FREE(s); -
src/io/sink_apple_audio.h
r082c88b ra9fd272 69 69 /** 70 70 71 close sink 72 73 \param s sink_apple_audio object, created with ::new_aubio_sink_apple_audio 74 75 \return 0 on success, non-zero on failure 76 77 */ 78 uint_t aubio_sink_apple_audio_close(aubio_sink_apple_audio_t * s); 79 80 /** 81 71 82 close sink and cleanup memory 72 83 -
src/io/sink_sndfile.c
r082c88b ra9fd272 116 116 } 117 117 118 uint_t aubio_sink_sndfile_close (aubio_sink_sndfile_t *s) { 119 if (!s->handle) { 120 return AUBIO_FAIL; 121 } 122 if (sf_close(s->handle)) { 123 AUBIO_ERR("Error closing file %s: %s", s->path, sf_strerror (NULL)); 124 return AUBIO_FAIL; 125 } 126 s->handle = NULL; 127 return AUBIO_OK; 128 } 129 118 130 void del_aubio_sink_sndfile(aubio_sink_sndfile_t * s){ 119 131 if (!s) return; 120 if (sf_close(s->handle)) { 121 AUBIO_ERR("Error closing file %s: %s", s->path, sf_strerror (NULL)); 122 } 132 aubio_sink_sndfile_close(s); 123 133 AUBIO_FREE(s->scratch_data); 124 134 AUBIO_FREE(s); -
src/io/sink_sndfile.h
r082c88b ra9fd272 68 68 /** 69 69 70 close sink 71 72 \param s sink_sndfile object, created with ::new_aubio_sink_sndfile 73 74 \return 0 on success, non-zero on failure 75 76 */ 77 uint_t aubio_sink_sndfile_close(aubio_sink_sndfile_t * s); 78 79 /** 80 70 81 close sink and cleanup memory 71 82 -
src/io/sink_wavwrite.c
r082c88b ra9fd272 153 153 154 154 beach: 155 AUBIO_ERR("sink_wavwrite: can not write %s atsamplerate %dHz\n",156 s->path, s->samplerate);155 //AUBIO_ERR("sink_wavwrite: failed creating %s with samplerate %dHz\n", 156 // s->path, s->samplerate); 157 157 del_aubio_sink_wavwrite(s); 158 158 return NULL; … … 182 182 } 183 183 184 voidaubio_sink_wavwrite_close(aubio_sink_wavwrite_t * s) {184 uint_t aubio_sink_wavwrite_close(aubio_sink_wavwrite_t * s) { 185 185 uint_t data_size = s->total_frames_written * s->bitspersample * s->channels / 8; 186 186 unsigned char buf[5]; 187 if (!s->fid) return ;187 if (!s->fid) return AUBIO_FAIL; 188 188 // ChunkSize 189 189 fseek(s->fid, 4, SEEK_SET); … … 197 197 } 198 198 s->fid = NULL; 199 return AUBIO_OK; 199 200 } 200 201 -
src/io/sink_wavwrite.h
r082c88b ra9fd272 68 68 /** 69 69 70 close sink 71 72 \param s sink_wavwrite object, create with ::new_aubio_sink_wavwrite 73 74 \return 0 on success, non-zero on failure 75 76 */ 77 uint_t aubio_sink_wavwrite_close(aubio_sink_wavwrite_t * s); 78 79 /** 80 70 81 close sink and cleanup memory 71 82
Note: See TracChangeset
for help on using the changeset viewer.