Hello,
I'm working with audio devices that have multiple streams, and I've
noticed an inconsistency when I try to get the device name and stream
names as displayed in Audio MIDI Setup.
For the first example, if I want to get the name of the overall audio
device, I would use the following code:
stat = AudioDeviceGetPropertyInfo(deviceID, 0, 1,
kAudioObjectPropertyName, &size, NULL);
if (!stat)
{
stat = AudioDeviceGetProperty(deviceID, 0, 1,
kAudioObjectPropertyName, &size, &srDeviceName);
if (!stat)
CFStringGetCStringPtr(srDeviceName, kCFStringEncodingMacRoman);
}
However, the above code is completely ineffective when trying to get
the name of a stream. In the second example, to get the name of a
stream, I found that I must use the following code:
aopa.mSelector = kAudioObjectPropertyName;
aopa.mScope = kAudioObjectPropertyScopeGlobal;
aopa.mElement = kAudioObjectPropertyElementMaster;
stat = AudioObjectGetPropertyDataSize(streamID, &aopa, 0, NULL, &size);
if (!stat)
{
stat = AudioObjectGetPropertyData(streamID, &aopa, size, NULL,
&size, &srStreamName);
if (!stat)
CFStringGetCStringPtr(srStreamName, kCFStringEncodingMacRoman);
}
Is there any reason why AudioDeviceGetProperty is sufficient for
getting the device name but not the stream name? I tried various
different values for inChannel, assuming that would be how to select
the stream within a device, and I also tried supplying the streamID
instead of the deviceID, but nothing worked. Is there any reason why
AudioObjectGetPropertyData is required to get the stream name? It
seems like the shortcut API for one name should work for the other as
well.
I'm working with CoreAudio 1.4.3 on Tiger 10.4.11 (since Leopard is
still not stable). I thought of trying this again on Leopard, but I
did not save examples of every code variation that I tried. I'm
hoping it's something simple...
Brian Willoughby
Sound Consulting