Changeset fe3e320 for src/io/source_apple_audio.c
- Timestamp:
- Aug 24, 2014, 7:24:09 PM (10 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:
- 3a1a5d6
- Parents:
- 810f975
- git-author:
- Paul Brossier <piem@piem.org> (08/22/14 17:36:25)
- git-committer:
- Paul Brossier <piem@piem.org> (08/24/14 19:24:09)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_apple_audio.c
r810f975 rfe3e320 299 299 300 300 uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) { 301 OSStatus err = noErr; 302 if ((sint_t)pos < 0) { 303 AUBIO_ERROR("source_apple_audio: error while seeking in %s " 304 "(can not seek at negative position %d)\n", 305 s->path, pos); 306 err = -1; 307 goto beach; 308 } 309 // check if we are not seeking out of the file 310 SInt64 fileLengthFrames = 0; 311 UInt32 propSize = sizeof(fileLengthFrames); 312 ExtAudioFileGetProperty(s->audioFile, 313 kExtAudioFileProperty_FileLengthFrames, &propSize, &fileLengthFrames); 314 // compute position in the source file, before resampling 315 smpl_t ratio = s->source_samplerate * 1. / s->samplerate; 316 SInt64 resampled_pos = (SInt64)ROUND( pos * ratio ); 317 if (resampled_pos > fileLengthFrames) { 318 AUBIO_ERR("source_apple_audio: trying to seek in %s at pos %d, " 319 "but file has only %d frames\n", 320 s->path, pos, (uint_t)(fileLengthFrames / ratio)); 321 err = -1; 322 goto beach; 323 } 301 324 // after a short read, the bufferList size needs to resetted to prepare for a full read 302 325 AudioBufferList *bufferList = &s->bufferList; 303 326 bufferList->mBuffers[0].mDataByteSize = s->block_size * s->channels * sizeof (short); 304 // compute position in the source file, before resampling 305 smpl_t ratio = s->source_samplerate * 1. / s->samplerate; 306 SInt64 resampled_pos = (SInt64)ROUND( pos * ratio ); 307 OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos); 327 // do the actual seek 328 err = ExtAudioFileSeek(s->audioFile, resampled_pos); 308 329 if (err) { 309 330 char_t errorstr[20]; … … 312 333 getPrintableOSStatusError(errorstr, err)); 313 334 } 335 #if 0 336 // check position after seek 337 { 338 SInt64 outFrameOffset = 0; 339 err = ExtAudioFileTell(s->audioFile, &outFrameOffset); 340 if (err) { 341 char_t errorstr[20]; 342 AUBIO_ERROR("source_apple_audio: error while seeking %s at %d " 343 "in ExtAudioFileTell (%s)\n", s->path, pos, 344 getPrintableOSStatusError(errorstr, err)); 345 } 346 AUBIO_DBG("source_apple_audio: asked seek at %d, tell got %d\n", 347 pos, (uint_t)(outFrameOffset / ratio + .5)); 348 } 349 #endif 350 beach: 314 351 return err; 315 352 }
Note: See TracChangeset
for help on using the changeset viewer.