From 5c4cb49ad85bebd54b744effd5ab15c8ec6f2a16 Mon Sep 17 00:00:00 2001 From: David Reid Date: Sun, 1 Feb 2026 16:59:13 +1000 Subject: [PATCH] Add `ma_device_get_channel_map()`. --- miniaudio.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index 525afbd9..5828b21c 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -9379,6 +9379,32 @@ This should only be called in single-threaded mode. It should be called in a loo MA_API ma_result ma_device_step(ma_device* pDevice, ma_blocking_mode blockingMode); +/* +Retrieves the channel map of the device. + + +Parameters +---------- +pDevice (in) + A pointer to the device whose channel map is being retrieved. + +deviceType (in) + Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose channel map is being retrieved. + +pChannelMap (out) + A pointer to the buffer that will receive the channel map. + +channelMapCap (in) + The capacity of `pChannelMap`. + + +Return Value +------------ +MA_SUCCESS if successful; any other error otherwise. +*/ +MA_API ma_result ma_device_get_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap); + + /* Performs post backend initialization routines for setting up internal data conversion. @@ -49461,6 +49487,23 @@ MA_API ma_result ma_device_step(ma_device* pDevice, ma_blocking_mode blockingMod return MA_SUCCESS; } +MA_API ma_result ma_device_get_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap) +{ + if (pDevice == NULL || pChannelMap == NULL) { + return MA_INVALID_ARGS; + } + + if (deviceType == ma_device_type_duplex) { + return MA_INVALID_ARGS; /* Don't know if the playback or capture side is being requested. */ + } + + if (deviceType == ma_device_type_playback) { + return ma_data_converter_get_input_channel_map(&pDevice->playback.converter, pChannelMap, channelMapCap); + } else { + return ma_data_converter_get_output_channel_map(&pDevice->capture.converter, pChannelMap, channelMapCap); + } +} + MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume) { if (pDevice == NULL) {