From 9964922b639d929e29e01e8b3b3d3f3655ce3f52 Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 14 Aug 2021 10:30:09 +1000 Subject: [PATCH] Fix some alignment errors with preallocation. --- miniaudio.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index 6ccb37fc..e0452e1a 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -40867,6 +40867,9 @@ static ma_result ma_lpf1_get_heap_layout(const ma_lpf1_config* pConfig, ma_lpf1_ pHeapLayout->r1Offset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_biquad_coefficient) * pConfig->channels; + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -41311,6 +41314,9 @@ static ma_result ma_lpf_get_heap_layout(const ma_lpf_config* pConfig, ma_lpf_hea pHeapLayout->sizeInBytes += sizeof(ma_lpf2) + lpf2HeapSizeInBytes; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -41699,6 +41705,9 @@ static ma_result ma_hpf1_get_heap_layout(const ma_hpf1_config* pConfig, ma_hpf1_ pHeapLayout->r1Offset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_biquad_coefficient) * pConfig->channels; + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -42143,6 +42152,9 @@ static ma_result ma_hpf_get_heap_layout(const ma_hpf_config* pConfig, ma_hpf_hea pHeapLayout->sizeInBytes += sizeof(ma_hpf2) + hpf2HeapSizeInBytes; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -42684,6 +42696,9 @@ static ma_result ma_bpf_get_heap_layout(const ma_bpf_config* pConfig, ma_bpf_hea pHeapLayout->sizeInBytes += sizeof(ma_bpf2) + bpf2HeapSizeInBytes; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -43782,6 +43797,9 @@ static ma_result ma_linear_resampler_get_heap_layout(const ma_linear_resampler_c pHeapLayout->sizeInBytes += lpfHeapSizeInBytes; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -45440,6 +45458,9 @@ static ma_result ma_channel_converter_get_heap_layout(const ma_channel_converter pHeapLayout->sizeInBytes += sizeof(ma_channel) * pConfig->channelsOut; } + /* Alignment for the next section. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + /* Whether or not we use weights of a shuffle table depends on the channel map themselves and the algorithm we've chosen. */ conversionPath = ma_channel_converter_config_get_conversion_path(pConfig); @@ -45456,6 +45477,9 @@ static ma_result ma_channel_converter_get_heap_layout(const ma_channel_converter pHeapLayout->sizeInBytes += sizeof(float ) * pConfig->channelsIn * pConfig->channelsOut; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -46230,6 +46254,9 @@ static ma_result ma_data_converter_get_heap_layout(const ma_data_converter_confi pHeapLayout->sizeInBytes += heapSizeInBytes; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -57713,6 +57740,9 @@ static ma_result ma_noise_get_heap_layout(const ma_noise_config* pConfig, ma_noi pHeapLayout->sizeInBytes += sizeof(double) * pConfig->channels; } + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; } @@ -63291,6 +63321,9 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_ pHeapLayout->inputBusCount = inputBusCount; pHeapLayout->outputBusCount = outputBusCount; + /* Make sure allocation size is aligned. */ + pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); + return MA_SUCCESS; }