2
我正在使用音頻隊列服務在iPhone上錄製音頻。儘管開始錄製時我遇到延遲問題。下面是代碼(約):使用AudioQueueStart()時的延遲
OSStatus status = AudioQueueNewInput(
&recordState.dataFormat, // 1
AudioInputCallback, // 2
&recordState, // 3
CFRunLoopGetCurrent(), // 4
kCFRunLoopCommonModes, // 5
0, // 6
&recordState.queue); // 7
// create buffers
for(int i = 0; i < NUM_BUFFERS; i++)
{
if (status == 0)
status = AudioQueueAllocateBuffer(recordState.queue, BUFFER_SIZE, &recordState.buffers[i]);
}
DebugLog(@"Starting recording\n");
OSStatus status = 0;
for(int i = 0; i < NUM_BUFFERS; i++)
{
if (status == 0)
status = AudioQueueEnqueueBuffer(recordState.queue, recordState.buffers[i], 0, NULL);
}
DebugLog(@"Queued buffers\n");
if (status == 0)
{
// start audio queue
status = AudioQueueStart(recordState.queue, NULL);
}
DebugLog(@"Started recording, status = %d\n", status);
日誌輸出看起來像這樣:
2009-06-30 19:18:59.631 app[24887:20b] Starting recording
2009-06-30 19:18:59.828 app[24887:20b] Queued buffers
2009-06-30 19:19:00.849 app[24887:20b] Started recording, status = 0
注意「排隊緩衝器」消息和第二「啓動記錄」的消息之間的1秒的延遲。除了在開始我的應用程序時開始錄製外,我有什麼想法可以擺脫它?
順便說一句,1秒在模擬器和設備中是非常一致的,似乎不受緩衝區數量或大小的影響。使用好的舊的單聲道16位PCM。
謝謝,這個頁面也有幫助:http://michael.tyson.id.au/2009/02/15/developing-loopy-part-2-implementation/ – sehugg 2009-07-01 17:29:39