Dev:IOAudio2Device

IOAudio2Device is a kernel-extension for playing (and recording?) audio.

It's interacted with exclusively by CoreAudio, so it can't be used directly if CoreAudio is in the picture.

(Info on this page may not be perfectly accurate)

Service properties
The most important ones are "input streams", "output streams" and "controls" which specify which streams/controls the driver provides.

See ioreg dumps for full information.

Notifications
Notifications are registered via IOConnectSetNotificationPort, they are sent on any audio event.

Some known events are:

Mapped memory
The following memory can be mapped via IOConnectMapMemory:

Note: Typically, streamId is 1 for input (sound recording) and 2 for output (sound playback).

where

Operation
Once audio is started, the driver periodically reads some data from the output buffer and plays it. It zeroes the data after reading it (so that silence is played if the buffer is being neglected by user-land)

Once the driver finishes going over the entire output buffer, it adds the amount of samples in the buffer to bufferSampleStart and updates bufferTime to the current time.

The output buffer sample format is typically 16-bit PCM stereo.

(input sound buffer operation is likely similar but with writing instead of reading).