File tree 1 file changed +19
-4
lines changed
1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,12 @@ OSStatus EZAudioFloatConverterCallback(AudioConverterRef inAudioConv
58
58
void *inUserData)
59
59
{
60
60
AudioBufferList *sourceBuffer = (AudioBufferList *)inUserData;
61
+
61
62
memcpy (ioData,
62
63
sourceBuffer,
63
64
sizeof (AudioBufferList) + (sourceBuffer->mNumberBuffers - 1 ) * sizeof (AudioBuffer));
65
+ sourceBuffer = NULL ;
66
+
64
67
return noErr ;
65
68
}
66
69
@@ -197,19 +200,31 @@ - (void)convertDataFromAudioBufferList:(AudioBufferList *)audioBufferList
197
200
toFloatBuffers : (float **)buffers
198
201
packetDescriptions : (AudioStreamPacketDescription *)packetDescriptions
199
202
{
200
- if (frames = = 0 )
203
+ if (frames ! = 0 )
201
204
{
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
+ }
202
212
203
- }
204
- else
205
- {
213
+ //
214
+ // Fill out the audio converter with the source buffer
215
+ //
206
216
[EZAudioUtilities checkResult: AudioConverterFillComplexBuffer (self .info->converterRef,
207
217
EZAudioFloatConverterCallback,
208
218
audioBufferList,
209
219
&frames,
210
220
self .info->floatAudioBufferList,
211
221
packetDescriptions ? packetDescriptions : self .info->packetDescriptions)
212
222
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
+ //
213
228
for (int i = 0 ; i < self.info ->floatAudioBufferList ->mNumberBuffers ; i++)
214
229
{
215
230
memcpy (buffers[i],
You can’t perform that action at this time.
0 commit comments