mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
ALSA: Add a new config option to use the default channel layout.
This can sometimes be more reliable than `snd_pcm_get_chmap()`.
This commit is contained in:
@@ -6834,6 +6834,7 @@ typedef struct ma_device_config_alsa
|
|||||||
ma_bool32 noAutoFormat; /* Opens the ALSA device with SND_PCM_NO_AUTO_FORMAT. */
|
ma_bool32 noAutoFormat; /* Opens the ALSA device with SND_PCM_NO_AUTO_FORMAT. */
|
||||||
ma_bool32 noAutoChannels; /* Opens the ALSA device with SND_PCM_NO_AUTO_CHANNELS. */
|
ma_bool32 noAutoChannels; /* Opens the ALSA device with SND_PCM_NO_AUTO_CHANNELS. */
|
||||||
ma_bool32 noAutoResample; /* Opens the ALSA device with SND_PCM_NO_AUTO_RESAMPLE. */
|
ma_bool32 noAutoResample; /* Opens the ALSA device with SND_PCM_NO_AUTO_RESAMPLE. */
|
||||||
|
ma_bool32 assumeDefaultChannelLayout; /* Forces the use of the "default" ALSA channel layout. */
|
||||||
} ma_device_config_alsa;
|
} ma_device_config_alsa;
|
||||||
|
|
||||||
MA_API ma_device_config_alsa ma_device_config_alsa_init(void);
|
MA_API ma_device_config_alsa ma_device_config_alsa_init(void);
|
||||||
@@ -29801,6 +29802,7 @@ static ma_result ma_device_init_by_type__alsa(ma_context* pContext, ma_context_s
|
|||||||
|
|
||||||
/* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */
|
/* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */
|
||||||
{
|
{
|
||||||
|
if (pDeviceConfigALSA->assumeDefaultChannelLayout) {
|
||||||
ma_snd_pcm_chmap_t* pChmap = NULL;
|
ma_snd_pcm_chmap_t* pChmap = NULL;
|
||||||
if (pContextStateALSA->snd_pcm_get_chmap != NULL) {
|
if (pContextStateALSA->snd_pcm_get_chmap != NULL) {
|
||||||
pChmap = pContextStateALSA->snd_pcm_get_chmap(pPCM);
|
pChmap = pContextStateALSA->snd_pcm_get_chmap(pPCM);
|
||||||
@@ -29855,6 +29857,10 @@ static ma_result ma_device_init_by_type__alsa(ma_context* pContext, ma_context_s
|
|||||||
/* Could not retrieve the channel map. Fall back to a hard-coded assumption. */
|
/* Could not retrieve the channel map. Fall back to a hard-coded assumption. */
|
||||||
ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels);
|
ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* The caller has requested that we always use the default ALSA channel layout. */
|
||||||
|
ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user