내가 지금하는 일 :CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer 반환 버퍼 크기는 조정 가능합니까?
iPod Lib에서 오디오를 재생하기 위해 콜백으로 실행되는 오디오 장치가 있습니다. 콜백에서 은 내가 CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer 느릅 나무가있는 AssetReader를 사용하는 아이팟 해방 독서를 들어 inNumberFrames
static OSStatus playbackMP3Callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
BeepTrackController *remoteIOplayer = (__bridge BeepTrackController *)inRefCon;
for (int i = 0 ; i < ioData->mNumberBuffers; i++){
AudioBuffer buffer = ioData->mBuffers[i];
if (remoteIOplayer->_isMP3Running == YES) {
SInt16 peak = [remoteIOplayer getMP3Samples:buffer.mData nrOfAudioFrames:inNumberFrames];
}else
memset(buffer.mData,0,ioData->mBuffers[i].mDataByteSize);
}
return noErr;
}
와 playxback 버퍼 (들)에 필요한 샘플의 수입니다 샘플의 숫자을 제공받을 오디오 콜백 버퍼 (들)에서 샘플의 requried 수와 다릅니다. 그녀의 단지 중요한 코드 라인 :
-(SInt16) getMP3Samples:(SInt16*)address nrOfAudioFrames:(NSInteger)nrOfFrames
... Loop ....
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
_mp3Control.nextbuffer,
NULL,
&audioBufferList,
sizeof(audioBufferList),
NULL,
NULL,
kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment,
&_mp3Control.blockBuffer
);
... SNIP ....
for (int bufferCount=currentBuffer; bufferCount < audioBufferList.mNumberBuffers; bufferCount++) {
SInt16* samples = (SInt16 *)audioBufferList.mBuffers[bufferCount].mData;
for (int i=currentSampleCount; i < audioBufferList.mBuffers[bufferCount].mDataByteSize/2 ; i++) {
currentSample = samples[i];
address [_mp3Control.currentSampleBufferCount++] = currentSample;
// End of Buffer reached?
if (_mp3Control.currentSampleBufferCount >nrOfFrames*2) {
_mp3Control.currentSampleBufferCount = 0;
currentBuffer = bufferCount;
currentSampleCount = i;
return currentSample;
}
}
}
그래서 내가하고 싶은 것을 CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer 정확히 내가 AUnit 콜백 내 콜백 버퍼에 필요한 시료의 양을 반환합니다. 구조가 동등하기 때문에 여기에서 의심되는 것은 이것을 동기화하는 방법이어야합니다. 오디오를 재생할 수 있지만 다른 크기의 버퍼에 못생긴 정적 포인터가 있기 때문에 더 우아하고 강력합니다.
이제 CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer 함수의 doco를 읽었으며 헤더 파일을 제외하고 여기에 많은 설명서가 없다는 것을 알고 있습니다.
힌트가 있습니까? 내 시도는 모든 소음에 실패 않았거나 충돌 ... 나는 OS 오디오가 요청 지정 크기가 버퍼 또는 필요성을 반환 것이라는 보장은 없습니다
감사합니다, 안드레아스
안녕하세요, 순환 버퍼에 대해 생각하지만 그 버퍼를 채우기 위해 나는 오디오 콜백 오디오 샘플의 건조 실행되지 않도록 버퍼에 데이터를로드 이벤트 시간의 일종 필요합니다. 난 그냥 다른 비동기 작업을 피하기 위해 어쩌면 그 길을 갈망하고 싶었 ... –