- Timestamp:
- Jan 24, 2014, 5:09:50 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:
- 5ab8e59
- Parents:
- 16dda03
- Location:
- src/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink_apple_audio.c
r16dda03 r98a3887 37 37 extern void freeAudioBufferList(AudioBufferList *bufferList); 38 38 extern CFURLRef getURLFromPath(const char * path); 39 char_t *getPrintableOSStatusError(char_t *str, OSStatus error); 39 40 40 41 #define MAX_SIZE 4096 // the maximum number of frames that can be written at a time … … 79 80 overwrite ? kAudioFileFlags_EraseFile : 0, &s->audioFile); 80 81 if (err) { 81 AUBIO_ERR("error when trying to create %s, in ExtAudioFileCreateWithURL, %d\n", s->path, (int)err); 82 char_t errorstr[20]; 83 AUBIO_ERR("sink_apple_audio: error when trying to create %s with " 84 "ExtAudioFileCreateWithURL (%s)\n", s->path, 85 getPrintableOSStatusError(errorstr, err)); 82 86 goto beach; 83 87 } 84 88 if (createAubioBufferList(&s->bufferList, s->channels, s->max_frames * s->channels)) { 85 AUBIO_ERR("error when creating buffer list for %s, out of memory? \n", s->path); 89 AUBIO_ERR("sink_apple_audio: error when creating buffer list for %s, " 90 "out of memory? \n", s->path); 86 91 goto beach; 87 92 } … … 115 120 116 121 if (err) { 117 AUBIO_ERROR("in aubio_sink_apple_audio_do, writing %s\n", s->path); 118 AUBIO_ERROR("ExtAudioFileWriteAsync failed with %d, switching to sync\n", (int)err); 122 char_t errorstr[20]; 123 AUBIO_ERROR("sink_apple_audio: error while writing %s " 124 "in ExtAudioFileWriteAsync (%s), switching to sync\n", s->path, 125 getPrintableOSStatusError(errorstr, err)); 119 126 s->async = false; 120 127 } else { … … 126 133 127 134 if (err) { 128 AUBIO_ERROR("in aubio_sink_apple_audio_do, writing %s\n", s->path); 129 AUBIO_ERROR("ExtAudioFileWrite failed with %d, aborting\n", (int)err); 135 char_t errorstr[20]; 136 AUBIO_ERROR("sink_apple_audio: error while writing %s " 137 "in ExtAudioFileWrite (%s)\n", s->path, 138 getPrintableOSStatusError(errorstr, err)); 130 139 } 131 140 } … … 136 145 OSStatus err = noErr; 137 146 if (!s || !s->audioFile) { 138 AUBIO_ERR(" failed erasing sink_apple_audio\n");147 AUBIO_ERR("sink_apple_audio: failed erasing\n"); 139 148 return; 140 149 } 141 150 err = ExtAudioFileDispose(s->audioFile); 142 if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err); 151 if (err) { 152 char_t errorstr[20]; 153 AUBIO_ERROR("sink_apple_audio: error while closing %s " 154 "in ExtAudioFileDispose (%s)\n", s->path, 155 getPrintableOSStatusError(errorstr, err)); 156 } 143 157 s->audioFile = NULL; 144 158 freeAudioBufferList(&s->bufferList); -
src/io/source_apple_audio.c
r16dda03 r98a3887 51 51 extern void freeAudioBufferList(AudioBufferList *bufferList); 52 52 extern CFURLRef getURLFromPath(const char * path); 53 char_t *getPrintableOSStatusError(char_t *str, OSStatus error); 53 54 54 55 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path); … … 80 81 CFURLRef fileURL = getURLFromPath(path); 81 82 err = ExtAudioFileOpenURL(fileURL, &s->audioFile); 82 if (err) { AUBIO_ERR("error when trying to access %s, in ExtAudioFileOpenURL, %d\n", s->path, (int)err); goto beach;} 83 if (err == -43) { 84 AUBIO_ERR("source_apple_audio: Failed opening %s, " 85 "file not found, or no read access\n", s->path); 86 goto beach; 87 } else if (err) { 88 char_t errorstr[20]; 89 AUBIO_ERR("source_apple_audio: Failed opening %s, " 90 "error in ExtAudioFileOpenURL (%s)\n", s->path, 91 getPrintableOSStatusError(errorstr, err)); 92 goto beach; 93 } 83 94 84 95 // create an empty AudioStreamBasicDescription … … 90 101 err = ExtAudioFileGetProperty(s->audioFile, 91 102 kExtAudioFileProperty_FileDataFormat, &propSize, &fileFormat); 92 if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;} 103 if (err) { 104 char_t errorstr[20]; 105 AUBIO_ERROR("source_apple_audio: Failed opening %s, " 106 "error in ExtAudioFileGetProperty (%s)\n", s->path, 107 getPrintableOSStatusError(errorstr, err)); 108 goto beach; 109 } 93 110 94 111 if (s->samplerate == 0) { … … 117 134 propSize, &clientFormat); 118 135 if (err) { 119 AUBIO_ERROR("error in ExtAudioFileSetProperty, %d\n", (int)err); 136 char_t errorstr[20]; 137 AUBIO_ERROR("source_apple_audio: Failed opening %s, " 138 "error in ExtAudioFileSetProperty (%s)\n", s->path, 139 getPrintableOSStatusError(errorstr, err)); 120 140 #if 1 121 141 // print client and format descriptions … … 158 178 UInt32 c, v, loadedPackets = s->block_size; 159 179 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList); 160 if (err) { AUBIO_ERROR("error in ExtAudioFileRead %s %d\n", s->path, (int)err); goto beach;} 180 if (err) { 181 char_t errorstr[20]; 182 AUBIO_ERROR("source_apple_audio: error while reading %s " 183 "with ExtAudioFileRead (%s)\n", s->path, 184 getPrintableOSStatusError(errorstr, err)); 185 goto beach; 186 } 161 187 162 188 short *data = (short*)s->bufferList.mBuffers[0].mData; … … 188 214 UInt32 c, v, loadedPackets = s->block_size; 189 215 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList); 190 if (err) { AUBIO_ERROR("source_apple_audio: error in ExtAudioFileRead, %d\n", (int)err); goto beach;} 216 if (err) { 217 char_t errorstr[20]; 218 AUBIO_ERROR("source_apple_audio: error while reading %s " 219 "with ExtAudioFileRead (%s)\n", s->path, 220 getPrintableOSStatusError(errorstr, err)); 221 goto beach; 222 } 191 223 192 224 short *data = (short*)s->bufferList.mBuffers[0].mData; … … 226 258 { 227 259 OSStatus err = noErr; 228 if (!s || !s->audioFile) { return 1; }260 if (!s || !s->audioFile) { return AUBIO_FAIL; } 229 261 err = ExtAudioFileDispose(s->audioFile); 230 if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err);231 262 s->audioFile = NULL; 232 return err; 263 if (err) { 264 char_t errorstr[20]; 265 AUBIO_ERROR("source_apple_audio: error while closing %s " 266 "in ExtAudioFileDispose (%s)\n", s->path, 267 getPrintableOSStatusError(errorstr, err)); 268 return err; 269 } 270 return AUBIO_OK; 233 271 } 234 272 … … 248 286 SInt64 resampled_pos = (SInt64)ROUND( pos * ratio ); 249 287 OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos); 250 if (err) AUBIO_ERROR("source_apple_audio: error in ExtAudioFileSeek (%d)\n", (int)err); 288 if (err) { 289 char_t errorstr[20]; 290 AUBIO_ERROR("source_apple_audio: error while seeking %s at %d " 291 "in ExtAudioFileSeek (%s)\n", s->path, pos, 292 getPrintableOSStatusError(errorstr, err)); 293 } 251 294 return err; 252 295 } -
src/io/utils_apple_audio.c
r16dda03 r98a3887 10 10 void freeAudioBufferList(AudioBufferList *bufferList); 11 11 CFURLRef getURLFromPath(const char * path); 12 char_t *getPrintableOSStatusError(char_t *str, OSStatus error); 12 13 13 14 int createAubioBufferList(AudioBufferList * bufferList, int channels, int max_source_samples) { … … 39 40 } 40 41 42 char_t *getPrintableOSStatusError(char_t *str, OSStatus error) 43 { 44 // see if it appears to be a 4-char-code 45 *(UInt32 *)(str + 1) = CFSwapInt32HostToBig(error); 46 if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) { 47 str[0] = str[5] = '\''; 48 str[6] = '\0'; 49 } else 50 // no, format it as an integer 51 sprintf(str, "%d", (int)error); 52 return str; 53 } 54 41 55 #endif /* __APPLE__ */
Note: See TracChangeset
for help on using the changeset viewer.