Potential Documentation Error in kAudioAggregateDevicePropertyTapList Sample Code

Hi, I believe I've found a potential error in the sample code on the documentation page for creating and using a process tap with an aggregate device. The issue is in the section explaining how to add a tap to the aggregate device. I have already filed a Feedback Assistant ticket on this (ID: FB17411663) but haven't heard back for months.

Capturing system audio with Core Audio taps

The sample code for modifying the kAudioAggregateDevicePropertyTapList incorrectly uses the tapID as the target AudioObjectID when calling AudioObjectSetPropertyData.

// (Code to get the list and potentially modify listAsArray)
if var listAsArray = list as? [CFString] {
    // ... (modification logic) ...

    // Set the list back on the aggregate device. <--- The comment is correct
    list = listAsArray as CFArray
    _ = withUnsafeMutablePointer(to: &list) { list in
        // INCORRECT: This call uses tapID as the target object.
        AudioObjectSetPropertyData(tapID, &propertyAddress, 0, nil, propertySize, list)
    }
}

The kAudioAggregateDevicePropertyTapList is a property that belongs to the aggregate device, not the individual tap. Therefore, to set this property, the AudioObjectSetPropertyData function must target the AudioObjectID of the aggregate device itself. Using tapID as the first argument is logically incorrect for this operation and will not update the aggregate device as intended.

Furthermore, the preceding AudioObjectGetPropertyData call to fetch the list also appears to use the incorrect tapID as its target in the sample.

The AudioObjectID for both getting and setting this property should be the ID of the aggregate device.

_ = AudioObjectGetPropertyData(aggregateDeviceID, &propertyAddress, 0, nil, &propertySize, &list)

_ = AudioObjectSetPropertyData(aggregateDeviceID, &propertyAddress, 0, nil, propertySize, newList)

Thank you!

Potential Documentation Error in kAudioAggregateDevicePropertyTapList Sample Code
 
 
Q