相关疑难解决方法(0)

从AVAssetReaderOutput读取数据时,iOS 5.0崩溃

我有这段代码用于从中读取数据AVAssetReaderOutput,该方法在iOS 4.0中运行良好,但是在5.0中它以最糟糕的访问方式崩溃,不知道为什么,任何人都有任何输入?

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];
}
Run Code Online (Sandbox Code Playgroud)

谢谢

丹尼尔

iphone audio avfoundation ios ios5

3
推荐指数
1
解决办法
3838
查看次数

标签 统计

audio ×1

avfoundation ×1

ios ×1

ios5 ×1

iphone ×1