shithub: aubio

Download patch

ref: 987fb86c97aee37ed3a19ebeee659eec6a7e88e0
parent: 6bbdcff5161f4e9c3cd1fb9e90fd802f8509a0b9
author: Paul Brossier <piem@piem.org>
date: Fri Mar 22 14:32:58 EDT 2013

src/io/source_apple_audio.c: reset mDataByteSize in case of short read

--- a/src/io/source_apple_audio.c
+++ b/src/io/source_apple_audio.c
@@ -237,6 +237,13 @@
 }
 
 uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) {
+  if (1) {
+    AudioBufferList *bufferList = &s->bufferList;
+    UInt32 samples = s->block_size * s->channels;
+    Float64 rateRatio = s->samplerate / s->source_samplerate;
+    uint_t segmentSize= (uint_t)(samples * rateRatio + .5);
+    bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
+  }
   SInt64 resampled_pos = (SInt64)ROUND( pos * s->source_samplerate * 1. / s->samplerate );
   OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos);
   if (err) AUBIO_ERROR("source_apple_audio: error in ExtAudioFileSeek (%d)\n", (int)err);