I have this snippet of code used to read data from an AVAssetReaderOutput
, the method works fine in iOS 4.0, however in 5.0 it crashes towards the end with bad access, not sure why, anyone have any input?
AVAssetReaderOutput *output=[myOutputs objectAtIndex:0];
int totalBuff=0;
while(TRUE)
{
CMSampleBufferRef ref=[output copyNextSampleBuffer];
if(ref==NULL)
break;
//copy data to file
//read next one
AudioBufferList audioBufferList;
NSMutableData *data=[[NSMutableData alloc] init];
CMBlockBufferRef blockBuffer;
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
for( int y=0; y<audioBufferList.mNumberBuffers; y++ )
{
AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
Float32 *frame = audioBuffer.mData;
NSLog(@"Gonna write %d", audioBuffer.mDataByteSize);
//crashes here
[data appendBytes:frame length:audioBuffer.mDataByteSize];
}
totalBuff++;
CFRelease(blockBuffer);
CFRelease(ref);
[fileHandle writeData:data];
[data release];
}
Thanks
Daniel
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…