2012-12-10 33 views
8

在我的應用程序中,我需要在這兩個不同的AudioUnit之間切換。 每當我從VPIO切換到RemoteIO時,錄製音量都會有所下降。相當大的下降。 雖然沒有改變播放音量。任何人都經歷過這個?RemoteIO和VPIO之間的錄製音量下降切換

下面是我做開關的代碼,它由路由更改觸發。 (我不太確定我是否做了正確的改變,所以我也在這裏問。)

如何解決錄音音量下降的問題?

謝謝,感謝任何幫助,我可以得到。

碼頭。

- (void)switchInputBoxTo : (OSType) inputBoxSubType 
{ 
OSStatus result; 

if (!remoteIONode) return; // NULL check 

// Get info about current output node 
AudioComponentDescription outputACD; 
AudioUnit currentOutputUnit; 

AUGraphNodeInfo(theGraph, remoteIONode, &outputACD, &currentOutputUnit); 

if (outputACD.componentSubType != inputBoxSubType) 
{ 
    AUGraphStop(theGraph); 
    AUGraphUninitialize(theGraph); 
    result = AUGraphDisconnectNodeInput(theGraph, remoteIONode, 0); 
    NSCAssert (result == noErr, @"Unable to disconnect the nodes in the audio processing graph. Error code: %d '%.4s'", (int) result, (const char *)&result); 
    AUGraphRemoveNode(theGraph, remoteIONode); 
    // Re-init as other type 

    outputACD.componentSubType = inputBoxSubType; 
    // Add the RemoteIO unit node to the graph 
    result = AUGraphAddNode (theGraph, &outputACD, &remoteIONode); 
    NSCAssert (result == noErr, @"Unable to add the replacement IO unit to the audio processing graph. Error code: %d '%.4s'", (int) result, (const char *)&result); 

    result = AUGraphConnectNodeInput(theGraph, mixerNode, 0, remoteIONode, 0); 
    // Obtain a reference to the I/O unit from its node 
    result = AUGraphNodeInfo (theGraph, remoteIONode, 0, &_remoteIOUnit); 
    NSCAssert (result == noErr, @"Unable to obtain a reference to the I/O unit. Error code: %d '%.4s'", (int) result, (const char *)&result); 

    //result = AudioUnitUninitialize(_remoteIOUnit); 

    [self setupRemoteIOTest]; // reinit all that remoteIO/voiceProcessing stuff 
    [self configureAndStartAudioProcessingGraph:theGraph]; 
} 
} 

回答

5

我用我的蘋果開發者支持。 這裏的支持說的:會導致

語音I/O的存在正在處理非常不同的輸入/輸出。我們不希望這些單位的收益水平完全相同,但是這些水平不應該像你指出的那樣急劇下降。

也就是說,核心音頻工程表明您的結果可能與語音模塊創建時相關,它也影響RIO實例。經過進一步的討論,Core Audio工程師認爲,由於您認爲級別差異非常激烈,因此如果您可以通過錄制某個錯誤來突出顯示您在語音I/O和遠程I/O以及您的測試代碼,因此我們可以嘗試在內部進行復制並查看這是否確實是一個錯誤。包含上面列出的單位IO單元測試的結果以及進一步的比較結果將是一個好主意。

沒有API控制此增益級別,所有內容都由操作系統根據音頻會話類別進行內部設置(例如,VPIO有望始終與PlayAndRecord一起使用)以及設置了哪個IO單元。一般來說,預計兩者都不會被同時實例化。

結論?我認爲這是一個錯誤。 :/

2

如果您沒有正確處置音頻設備,有一些關於低音量問題的討論。基本上,第一個音頻組件停留在內存中,任何連續的播放都會在您的或其他應用程序下閃爍,導致音量下降。

解決方案: 音頻單元AudioComponentInstance的,必須使用AudioComponentInstanceDispose()被釋放。

+1

嗨,洛基,我試過了。因爲我使用AUGraphNodeInfo(theGraph,remoteIONode,0,&_remoteIOUnit);獲取remoteIO實例,似乎我無法使用AudioComponentInstanceDispose(它崩潰)。我讀過你似乎在談論的帖子。似乎並不適合我:/ – lppier

2

當我從語音處理io(PlayAndRecord)轉到遠程IO(SoloAmbient)時,我更改了音頻會話類別。確保在更改前暫停音頻會話。您還必須取消初始化您的音頻圖。

+0

這適用於我,謝謝! – scharli