6

複数のオーディオ入力を処理する必要のあるプログラムを書いています。

現在、AudioQueuesを使用して入力を取得していますが、これはデフォルトの入力デバイスからのみです。

次のいずれかにする方法はありますか?

  • AudioQueuesが使用する入力デバイスを選択します。
  • デフォルトの入力デバイスを変更します。

Core-AudioでkAudioHardwarePropertyDevicesを使用して出力デバイスのリストを取得できることは知っていますが、入力デバイスに使用できる同様のデバイスはありますか?

4

2 に答える 2

3

私はしばらくの間これを行う方法に頭をぶつけて、最終的にそれを理解しました:

BOOL isMic = NO;
BOOL isSpeaker = NO;

AudioDeviceID device        = audioDevices[i];

// Determine direction of the device by asking for the number of input or 
// output streams.
propertyAddress.mSelector   = kAudioDevicePropertyStreams;
propertyAddress.mScope      = kAudioDevicePropertyScopeInput;

UInt32 dataSize             = 0;
OSStatus status             = AudioObjectGetPropertyDataSize(device, 
                                                             &propertyAddress, 
                                                             0, 
                                                             NULL, 
                                                             &dataSize);        
UInt32 streamCount          = dataSize / sizeof(AudioStreamID);

if (streamCount > 0) 
{
    isMic = YES;
}

propertyAddress.mScope  = kAudioDevicePropertyScopeOutput;      
dataSize                = 0;
status                  = AudioObjectGetPropertyDataSize(device, 
                                                         &propertyAddress, 
                                                         0, 
                                                         NULL,  
                                                         &dataSize);        
streamCount             = dataSize / sizeof(AudioStreamID);

if (streamCount > 0) 
{
    isSpeaker = YES;
}

ご覧のとおり、重要な部分はScopeInput/ScopeOutputパラメーター値を使用することです。

于 2011-12-02T21:38:29.083 に答える
2

kAudioHardwarePropertyDevices出力デバイスと入力デバイスの両方に使用されます。デバイスは、入力チャネルと出力チャネルの両方を持つことも、入力チャネルまたは出力チャネルのみを持つこともできます。

ほとんどのAudioDevice...関数は、ブールisInputパラメーターを受け取るため、デバイスの入力側を照会できます。

于 2010-07-08T05:56:01.527 に答える