From f6e5cf10ae10494cf7215a2b2262092e8247dd7f Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 25 Jun 2022 18:11:17 +1000 Subject: [PATCH] Fix a crash when initializing a channel converter. Public issue https://github.com/mackron/miniaudio/issues/482 --- CHANGES.md | 1 + miniaudio.h | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e0949000..1a644613 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ v0.11.10 - TBD ===================== * Add support for setting the device notification callback when initializing an engine object. +* Fix a crash when initializing a channel converter. v0.11.9 - 2022-04-20 diff --git a/miniaudio.h b/miniaudio.h index 529270de..79676b0e 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -51185,12 +51185,12 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert { /* Unmapped input channels. */ for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { - ma_channel channelPosIn = pConverter->pChannelMapIn[iChannelIn]; + ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn); if (ma_is_spatial_channel_position(channelPosIn)) { if (!ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, channelPosIn)) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { - ma_channel channelPosOut = pConverter->pChannelMapOut[iChannelOut]; + ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut); if (ma_is_spatial_channel_position(channelPosOut)) { float weight = 0; @@ -51216,12 +51216,12 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert /* Unmapped output channels. */ for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { - ma_channel channelPosOut = pConverter->pChannelMapOut[iChannelOut]; + ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut); if (ma_is_spatial_channel_position(channelPosOut)) { if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, channelPosOut)) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { - ma_channel channelPosIn = pConverter->pChannelMapIn[iChannelIn]; + ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn); if (ma_is_spatial_channel_position(channelPosIn)) { float weight = 0;