Hi
Hopefully a simple question. I just reached for AudioObjectShow() to help debug stuff and it does not appear to work on audio devices or audio streams. It prints nothing for them. It does work on AudiokAudioObjectSystemObject, I've not explored what else it does or does not work on. I could not find any other posts about this, it it expected to work? On all audio objects? I'm on macOS 14.4.
Here is a simple demo. AudioObjectShow() prints out info for the System AudiokAudioObjectSystemObject but then prints nothing as we loop through the audio devices in the system (and same for all streams on all these devices, but I'm not showing that here).
#include <CoreAudio/AudioHardware.h>
static const AudioObjectPropertyAddress devicesAddress = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain
};
static const AudioObjectPropertyAddress nameAddress = {
kAudioObjectPropertyName,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain
};
int main(int argc, const char *argv[]) {
UInt32 size;
AudioObjectID *audioDevices;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &devicesAddress, 0, NULL, &size);
audioDevices = (AudioObjectID *) malloc(size);
AudioObjectGetPropertyData(kAudioObjectSystemObject, &devicesAddress, 0, NULL, &size, audioDevices);
UInt32 nDevices = size / sizeof(AudioObjectID);
printf("--- AudioObjectShow(kAudioObjectSystemObject):\n");
AudioObjectShow(kAudioObjectSystemObject);
for (int i=0; i < nDevices; i++) {
printf("-------------------------------------------------\n");
printf("audioDevices[%d] = 0x%x\n", i, audioDevices[i]);
AudioObjectGetPropertyDataSize(audioDevices[i], &nameAddress, 0, NULL, &size);
CFStringRef cfString = malloc(size);
AudioObjectGetPropertyData(audioDevices[i], &nameAddress, 0, NULL, &size, &cfString);
CFShow(cfString);
//AudioObjectShow() give us anything?
printf("--- AudioObjectShow(audioDevices[%d]=0x%x):\n", i, audioDevices[i]);
AudioObjectShow(audioDevices[i]);
printf("---\n");
}
}
Start of output...
AudioObjectID: 0x1
Class: Audio System Object
Name: The Audio System Object
-------------------------------------------------
audioDevices[0] = 0xd2
Darryl\u2019s iPhone Microphone
--- AudioObjectShow(audioDevices[0]=0xd2):
---
-------------------------------------------------
audioDevices[1] = 0x41
LG UltraFine Display Audio
--- AudioObjectShow(audioDevices[1]=0x41):
---
-------------------------------------------------
audioDevices[2] = 0x3b
LG UltraFine Display Audio
--- AudioObjectShow(audioDevices[2]=0x3b):
---
-------------------------------------------------
audioDevices[3] = 0x5d
BlackHole 16ch
--- AudioObjectShow(audioDevices[3]=0x5d):
---
-------------------------------------------------