mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Fix a bug where it's possible for the internal channel map to be wrong.
This commit is contained in:
@@ -18886,6 +18886,7 @@ mal_result mal_device_init__sdl(mal_context* pContext, mal_device_type type, con
|
||||
pDevice->internalFormat = mal_format_from_sdl(obtainedSpec.format);
|
||||
pDevice->internalChannels = obtainedSpec.channels;
|
||||
pDevice->internalSampleRate = (mal_uint32)obtainedSpec.freq;
|
||||
mal_get_standard_channel_map(mal_standard_channel_map_default, pDevice->internalChannels, pDevice->internalChannelMap);
|
||||
pDevice->bufferSizeInFrames = obtainedSpec.samples;
|
||||
pDevice->periods = 1; // SDL doesn't seem to tell us what the period count is. Just set this 1.
|
||||
|
||||
@@ -19800,6 +19801,13 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure the internal channel map was set correctly by the backend. If it's not valid, just fall back to defaults.
|
||||
if (!mal_channel_map_valid(pDevice->internalChannels, pDevice->internalChannelMap)) {
|
||||
mal_get_standard_channel_map(mal_standard_channel_map_default, pDevice->internalChannels, pDevice->internalChannelMap);
|
||||
}
|
||||
|
||||
|
||||
// If the format/channels/rate is using defaults we need to set these to be the same as the internal config.
|
||||
if (pDevice->usingDefaultFormat) {
|
||||
pDevice->format = pDevice->internalFormat;
|
||||
|
||||
Reference in New Issue
Block a user