AudioIODevice problem

Hi Jules,

You know, some CoreAudio drivers includes Apple’s Built-in IO for IntelMacs provide drivers for Input/Output separately.

These three CoreAudio devices are found on MacBook Pro.

Built-in Mic
Built-in Input
Built-in Output

At first, I think these devices should be combined like Logic Pro 7.2 is doing. Logic deals those devices as two devices.

Built-in Mic
Built-in Input

Built-in Output is silently combined to Built-in Mic and Built-in Input.

Since we can’t force end users to make aggregate device in AudioMIDI setup, this should be implemented in Juce, I think.

Regarding this issue, there is a fatal assert issue in juce_mac_CoreAudio.cpp

[code] if (OK (AudioDeviceGetProperty (deviceID, 0, true, kAudioDevicePropertyLatency, &size, &lat)))
inputLatency = (int)lat;

    if (OK (AudioDeviceGetProperty (deviceID, 0, false, kAudioDevicePropertyLatency, &size, &lat)))
        outputLatency = (int)lat;[/code]

AudioDeviceGetProperty() always return false when the device doesn’t have inputs or outputs.

Best regards,
Masanao Hayashi
Korg Inc.

Yes, probably should be tweaked to handle this, though I just don’t understand why apple have done it though - only the drivers themselves have the info about which of them should be combined, and expecting the application to do this by guessing which driver names are similar is crazy.

And I suppose the other lines should have the assertion removed:

[code] if (AudioDeviceGetProperty (deviceID, 0, true, kAudioDevicePropertyLatency, &size, &lat) == noErr)
inputLatency = (int) lat;

    if (AudioDeviceGetProperty (deviceID, 0, false, kAudioDevicePropertyLatency, &size, &lat) == noErr)
        outputLatency = (int) lat;


Ok, how about this as a replacement algorithm for matching the devices.

I’ve not tried this code, and don’t have an intel mac, but it might do the trick:

[code] AudioIODevice* createDevice (const String& deviceName)
jassert (hasScanned); // need to call scanForDevices() before doing this

    const int index = names.indexOf (deviceName);

    if (index >= 0)
        int secondIndex = names.indexOf (deviceName, true, index + 1);

        if (secondIndex < 0)
            secondIndex = names.indexOf (deviceName.replace (T("output"), T("input"), true), true, 0);

        if (secondIndex < 0)
            secondIndex = names.indexOf (deviceName.replace (T("input"), T("output"), true), true, 0);

        return new CoreAudioIODevice (deviceName,
                                      ids [index],
                                      ids [secondIndex]);

    return 0;

Although I forgot about the exact thread in CoreAudio ML, the senior or lead engineer mentioned about it months ago… I will search it and let you know.

I don’t know who should take care about this issue, the library writer or application programmer. But anyway, at least we need an information about which devices should be combined. I don’t think the key is the name of the device… (Maybe that ML thread mentioned about it…)

Best regards,
Masanao Hayashi

I asked “How to combine Built-In audio devices?” in the CoreAudio ML, and the engineer replied as follows. :slight_smile:

This is precisely what the HAL property, kAudioDevicePropertyRelatedDevices, is for:

@constant kAudioDevicePropertyRelatedDevices An array of AudioDeviceIDs for devices related to the AudioDevice. For IOAudio-based devices, a AudioDevices are related if they share the same IOAudioDevice object.


Ah - I’d never seen that property before (maybe it’s new?)

Thanks, I’ll put in some code using that and let you have a go…