Skip to content

Commit ea4536f

Browse files
committedJan 24, 2016
Added fix for invalid input buffer size error
1 parent f4ee040 commit ea4536f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed
 

‎EZAudio/EZAudioFloatConverter.m

+19-4
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ OSStatus EZAudioFloatConverterCallback(AudioConverterRef inAudioConv
5858
void *inUserData)
5959
{
6060
AudioBufferList *sourceBuffer = (AudioBufferList *)inUserData;
61+
6162
memcpy(ioData,
6263
sourceBuffer,
6364
sizeof(AudioBufferList) + (sourceBuffer->mNumberBuffers - 1) * sizeof(AudioBuffer));
65+
sourceBuffer = NULL;
66+
6467
return noErr;
6568
}
6669

@@ -197,19 +200,31 @@ - (void)convertDataFromAudioBufferList:(AudioBufferList *)audioBufferList
197200
toFloatBuffers:(float **)buffers
198201
packetDescriptions:(AudioStreamPacketDescription *)packetDescriptions
199202
{
200-
if (frames == 0)
203+
if (frames != 0)
201204
{
205+
//
206+
// Make sure the data size coming in is consistent with the number
207+
// of frames we're actually getting
208+
//
209+
for (int i = 0; i < audioBufferList->mNumberBuffers; i++) {
210+
audioBufferList->mBuffers[i].mDataByteSize = frames * self.info->inputFormat.mBytesPerFrame;
211+
}
202212

203-
}
204-
else
205-
{
213+
//
214+
// Fill out the audio converter with the source buffer
215+
//
206216
[EZAudioUtilities checkResult:AudioConverterFillComplexBuffer(self.info->converterRef,
207217
EZAudioFloatConverterCallback,
208218
audioBufferList,
209219
&frames,
210220
self.info->floatAudioBufferList,
211221
packetDescriptions ? packetDescriptions : self.info->packetDescriptions)
212222
operation:"Failed to fill complex buffer in float converter"];
223+
224+
//
225+
// Copy the converted buffers into the float buffer array stored
226+
// in memory
227+
//
213228
for (int i = 0; i < self.info->floatAudioBufferList->mNumberBuffers; i++)
214229
{
215230
memcpy(buffers[i],

0 commit comments

Comments
 (0)
Please sign in to comment.