Changeset d013a93 for src/io/sink_apple_audio.c
- Timestamp:
- Dec 17, 2018, 4:42:29 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
- Children:
- d286fe4
- Parents:
- 2de7cfa (diff), 09b4be9 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink_apple_audio.c
r2de7cfa rd013a93 62 62 s->async = false; 63 63 64 if ( (uri == NULL) || (str len(uri) < 1) ) {64 if ( (uri == NULL) || (strnlen(uri, PATH_MAX) < 1) ) { 65 65 AUBIO_ERROR("sink_apple_audio: Aborted opening null path\n"); 66 66 goto beach; 67 67 } 68 if (s->path != NULL) AUBIO_FREE(s->path); 68 69 69 s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX) + 1); 70 70 strncpy(s->path, uri, strnlen(uri, PATH_MAX) + 1); … … 92 92 return s; 93 93 beach: 94 AUBIO_FREE(s);94 del_aubio_sink_apple_audio(s); 95 95 return NULL; 96 96 } … … 103 103 s->samplerate = samplerate; 104 104 // automatically open when both samplerate and channels have been set 105 if ( s->samplerate != 0 &&s->channels != 0) {105 if (/* s->samplerate != 0 && */ s->channels != 0) { 106 106 return aubio_sink_apple_audio_open(s); 107 107 } … … 116 116 s->channels = channels; 117 117 // automatically open when both samplerate and channels have been set 118 if (s->samplerate != 0 && s->channels != 0) {118 if (s->samplerate != 0 /* && s->channels != 0 */) { 119 119 return aubio_sink_apple_audio_open(s); 120 120 } … … 176 176 UInt32 c, v; 177 177 short *data = (short*)s->bufferList.mBuffers[0].mData; 178 if (write > s->max_frames) { 179 AUBIO_WRN("sink_apple_audio: trying to write %d frames, max %d\n", write, s->max_frames); 180 write = s->max_frames; 181 } 182 smpl_t *buf = write_data->data; 183 184 if (buf) { 185 for (c = 0; c < s->channels; c++) { 186 for (v = 0; v < write; v++) { 187 data[v * s->channels + c] = 188 FLOAT_TO_SHORT(buf[ v * s->channels + c]); 189 } 190 } 191 } 192 aubio_sink_apple_audio_write(s, write); 178 uint_t length = aubio_sink_validate_input_length("sink_apple_audio", s->path, 179 s->max_frames, write_data->length, write); 180 181 for (c = 0; c < s->channels; c++) { 182 for (v = 0; v < length; v++) { 183 data[v * s->channels + c] = FLOAT_TO_SHORT(write_data->data[v]); 184 } 185 } 186 187 aubio_sink_apple_audio_write(s, length); 193 188 } 194 189 … … 196 191 UInt32 c, v; 197 192 short *data = (short*)s->bufferList.mBuffers[0].mData; 198 if (write > s->max_frames) { 199 AUBIO_WRN("sink_apple_audio: trying to write %d frames, max %d\n", write, s->max_frames); 200 write = s->max_frames; 201 } 202 smpl_t **buf = write_data->data; 203 204 if (buf) { 205 for (c = 0; c < s->channels; c++) { 206 for (v = 0; v < write; v++) { 207 data[v * s->channels + c] = 208 FLOAT_TO_SHORT(buf[c][v]); 209 } 210 } 211 } 212 aubio_sink_apple_audio_write(s, write); 193 uint_t channels = aubio_sink_validate_input_channels("sink_apple_audio", 194 s->path, s->channels, write_data->height); 195 uint_t length = aubio_sink_validate_input_length("sink_apple_audio", s->path, 196 s->max_frames, write_data->length, write); 197 198 for (c = 0; c < channels; c++) { 199 for (v = 0; v < length; v++) { 200 data[v * s->channels + c] = FLOAT_TO_SHORT(write_data->data[c][v]); 201 } 202 } 203 204 aubio_sink_apple_audio_write(s, length); 213 205 } 214 206 … … 258 250 259 251 void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) { 260 if (s->audioFile) aubio_sink_apple_audio_close (s); 261 if (s->path) AUBIO_FREE(s->path); 252 AUBIO_ASSERT(s); 253 if (s->audioFile) 254 aubio_sink_apple_audio_close (s); 255 if (s->path) 256 AUBIO_FREE(s->path); 262 257 freeAudioBufferList(&s->bufferList); 263 258 AUBIO_FREE(s); 264 return;265 259 } 266 260
Note: See TracChangeset
for help on using the changeset viewer.