Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add raw device enumeration to Core Audio backend #165

Closed
wants to merge 0 commits into from

Conversation

tokyovigilante
Copy link
Contributor

This is the start of integer IO support for Core Audio on macOS. This first commit adds support for enumerating the raw IO streams available on all attached hardware devices (these will typically be 24 +/ 16 bit signed integer format at various sample rates).

The device is then configured and started using AudioDeviceStart() rather than AudioOutputUnitStart() for AudioUnit based playback. The advantage is bypassing the mixer. Orthogonal to this is "hog" or exclusive mode which disables output for a device other than the application "hogging" the device. This is useful for SPDIF and high-res output to a separate amplifier etc.

The code is not yet complete and not intended to be merged but device enumeration is working as can be seen in the sio_device_list output for my MBP:

--------Input Devices--------

Built-in Microphone (default)
  id: AppleHDAEngineInput:1F,3,0,1,0:1
  channel layouts:
    Stereo
  current layout: Stereo
  sample rates:
    44100 - 44100
  current sample rate: 44100
  formats: signed 16-bit LE, signed 32-bit LE, float 32-bit LE, float 64-bit LE
  min software latency: 0.00031746 sec
  max software latency: 0.00000000 sec
  current software latency: 0.01160998 sec

Built-in Microphone (raw)
  id: AppleHDAEngineInput:1F,3,0,1,0:1
  channel layouts:
    Stereo
  current layout: Stereo
  sample rates:
    96000 - 96000
    88200 - 88200
    48000 - 48000
    44100 - 44100
  formats: signed 24-bit LE, signed 16-bit LE
  min software latency: 0.00000000 sec
  max software latency: 0.09287982 sec
  current software latency: 0.01160998 sec


--------Output Devices--------

Built-in Output (default)
  id: AppleHDAEngineOutput:1F,3,0,1,1:0
  channel layouts:
    Stereo
  current layout: Stereo
  sample rates:
    44100 - 44100
    48000 - 48000
    96000 - 96000
  current sample rate: 96000
  formats: signed 16-bit LE, signed 32-bit LE, float 32-bit LE, float 64-bit LE
  min software latency: 0.00030208 sec
  max software latency: 0.00000000 sec
  current software latency: 0.00533333 sec

Built-in Output (raw)
  id: AppleHDAEngineOutput:1F,3,0,1,1:0
  channel layouts:
    Stereo
  current layout: Stereo
  sample rates:
    96000 - 96000
    48000 - 48000
    44100 - 44100
  formats: signed 24-bit LE
  min software latency: 0.00000000 sec
  max software latency: 0.04266667 sec
  current software latency: 0.00533333 sec


4 devices found

@andrewrk
Copy link
Owner

Looks good so far.

@andrewrk
Copy link
Owner

how's this going? is it ready for merge?

@tokyovigilante
Copy link
Contributor Author

tokyovigilante commented Oct 23, 2017

Hi Andrew,

I haven't performed a huge amount of testing as I've been tied up with other things, but yes the current commit seems to be working well, with enumeration, selection, opening and playback, including pause and stop all satisfactory. I think it's ready for review and merge, although any feedback you have on code quality and style is welcome.

Only caveat is the danger of opening a device in raw mode at 100% volume by default, as 0dBFS is a dangerous thing for the unwary... This isn't unique to macOS though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants