A way to get preferred audio device channels
A way to get preferred audio device channels
- Subject: A way to get preferred audio device channels
- From: Xiaofeng Li <email@hidden>
- Date: Mon, 26 Mar 2012 18:35:01 -0500
Hi There,
I am trying to get preferred channels supported of an audio
input/output device in my Mac pro,
I tried the following code which I saw in stackoverflow, I am using
bufferList->mNumberBuffers to tell channels, is this correct? I tried
to kAudioDevicePropertyScopeOutput and my default Buildin-output is
shown only 1 channel, I think the speaker has two channels which is
wrong. The bufferList I am using is an object of AudioBufferList.
If this is not correct, shall I use AudioChannelLayout?
Your comment is highly appreciated!
//code
....
thePropertyAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
thePropertyAddress.mScope = kAudioDevicePropertyScopeInput;
result = AudioObjectGetPropertyDataSize(theDeviceIDs[i],
&thePropertyAddress, 0, NULL, &thePropSize);
if(kAudioHardwareNoError != result) {
fprintf(stderr, "AudioObjectGetPropertyDataSize
(kAudioDevicePropertyStreamConfiguration) failed: %i\n",(int) result);
continue;
}
AudioBufferList *bufferList = (AudioBufferList *)malloc(thePropSize);
if(NULL == bufferList) {
fputs("Unable to allocate memory", stderr);
}
result = AudioObjectGetPropertyData(theDeviceIDs[i],
&thePropertyAddress, 0, NULL, &thePropSize, bufferList);
//TODO the following error needs to be handled
if(kAudioHardwareNoError != result || 0 == bufferList->mNumberBuffers)
{....
}
--
Xiaofeng Li
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden