kcat/openal-soft

Surround sound support on macOS/CoreAudio?

Closed this issue · 1 comments

I'm maintaining a game that uses OpenAL. I have some experiences working with CoreAudio but my OpenAPI experience is limited. Apologies in advance...

I have an Apple Studio Display which is a 5.1 device. If I go into Audio Midi Setup I can see all the output speakers and test playback on them independently. However - in the software I'm working on - the FmtChans for the device is always DevFmtStereo.

I assumed that maybe I was misinterpreting the meaning of those values in the device structure - so I also ran OpenAL-Info. It also reports my Studio Display as a Stereo Device even though it is a multichannel device and is configured as such.

** Info for device "Studio Display Speakers" **
ALC version: 1.1
ALC extensions:
    ALC_ENUMERATE_ALL_EXT, ALC_ENUMERATION_EXT, ALC_EXT_CAPTURE, ALC_EXT_debug,
    ALC_EXT_DEDICATED, ALC_EXT_direct_context, ALC_EXT_disconnect, ALC_EXT_EFX,
    ALC_EXT_thread_local_context, ALC_SOFT_device_clock, ALC_SOFT_HRTF,
    ALC_SOFT_loopback, ALC_SOFT_loopback_bformat, ALC_SOFT_output_limiter,
    ALC_SOFT_output_mode, ALC_SOFT_pause_device, ALC_SOFT_reopen_device,
    ALC_SOFT_system_events
Available HRTF profiles:
    Built-In HRTF
Available events:
    ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT for ALC_PLAYBACK_DEVICE_SOFT - SUPPORTED
    ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT for ALC_CAPTURE_DEVICE_SOFT - SUPPORTED
    ALC_EVENT_TYPE_DEVICE_ADDED_SOFT for ALC_PLAYBACK_DEVICE_SOFT - NOT SUPPORTED
    ALC_EVENT_TYPE_DEVICE_ADDED_SOFT for ALC_CAPTURE_DEVICE_SOFT - NOT SUPPORTED
    ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT for ALC_PLAYBACK_DEVICE_SOFT - NOT SUPPORTED
    ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT for ALC_CAPTURE_DEVICE_SOFT - NOT SUPPORTED
Device output mode: Stereo (basic)
Device sample rate: 48000hz
Device HRTF profile: (disabled)
Device number of mono sources: 255
Device number of stereo sources: 1
OpenAL vendor string: OpenAL Community
OpenAL renderer string: OpenAL Soft
OpenAL version string: 1.1 ALSOFT 1.23.1
OpenAL extensions:
    AL_EXT_ALAW, AL_EXT_BFORMAT, AL_EXT_debug, AL_EXT_direct_context,
    AL_EXT_DOUBLE, AL_EXT_EXPONENT_DISTANCE, AL_EXT_FLOAT32, AL_EXT_IMA4,
    AL_EXT_LINEAR_DISTANCE, AL_EXT_MCFORMATS, AL_EXT_MULAW,
    AL_EXT_MULAW_BFORMAT, AL_EXT_MULAW_MCFORMATS, AL_EXT_OFFSET,
    AL_EXT_source_distance_model, AL_EXT_SOURCE_RADIUS, AL_EXT_STATIC_BUFFER,
    AL_EXT_STEREO_ANGLES, AL_LOKI_quadriphonic, AL_SOFT_bformat_ex,
    AL_SOFTX_bformat_hoa, AL_SOFT_block_alignment, AL_SOFT_buffer_length_query,
    AL_SOFT_callback_buffer, AL_SOFTX_convolution_effect,
    AL_SOFT_deferred_updates, AL_SOFT_direct_channels,
    AL_SOFT_direct_channels_remix, AL_SOFT_effect_target, AL_SOFT_events,
    AL_SOFT_gain_clamp_ex, AL_SOFTX_hold_on_disconnect, AL_SOFT_loop_points,
    AL_SOFTX_map_buffer, AL_SOFT_MSADPCM, AL_SOFT_source_latency,
    AL_SOFT_source_length, AL_SOFTX_source_panning, AL_SOFT_source_resampler,
    AL_SOFT_source_spatialize, AL_SOFT_source_start_delay, AL_SOFT_UHJ,
    AL_SOFT_UHJ_ex
Available resamplers:
    Nearest
    Linear
    Cubic Spline
    4-point Gaussian *
    11th order Sinc (fast)
    11th order Sinc
    23rd order Sinc (fast)
    23rd order Sinc
EFX version: 1.0
Max auxiliary sends: 2
Supported filters:
    Low-pass, High-pass, Band-pass
Supported effects:
    EAX Reverb, Reverb, Chorus, Distortion, Echo, Flanger, Frequency Shifter,
    Vocal Morpher, Pitch Shifter, Ring Modulator, Autowah, Compressor,
    Equalizer, Dedicated Dialog, Dedicated LFE

I tried reading through the CoreAudio backed but couldn't quite figure out how multichannel in the backend would connect to the audio rendering. I'm happy to keep digging further - but I wanted to check: Is multichannel rendering expected to work with the CoreAudio backend? Should there be other diagnostics I should perform to evaluate if 5.1 audio is working?

I did some more digging and the kAudioDevicePropertyStreamConfiguration property from CoreAudio is returning a channel count of 2. So the issue seems to be deeper than OpenAL.

I'll continue digging but I'll clearly need to figure out why CoreAudio itself is defaulting to stereo output for this device.