From 68cf405883df88a81c29b5a9727115e028f54a2a Mon Sep 17 00:00:00 2001 From: hexptr Date: Sun, 12 Jul 2020 19:36:25 +0100 Subject: [PATCH] fix mufft crash caused by unaligned input buffer --- src/RageUtil/Sound/RageSound.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/RageUtil/Sound/RageSound.cpp b/src/RageUtil/Sound/RageSound.cpp index fd6b955737..7f31cd2cc6 100644 --- a/src/RageUtil/Sound/RageSound.cpp +++ b/src/RageUtil/Sound/RageSound.cpp @@ -355,11 +355,13 @@ RageSound::GetDataToPlay(float* pBuffer, copy(pBuffer, until, back_inserter(recentPCMSamples)); if (recentPCMSamples.size() >= recentPCMSamplesBufferSize) { auto out = static_cast(fftBuffer); - auto n = recentPCMSamplesBufferSize; auto plan = mufft_create_plan_1d_r2c(recentPCMSamplesBufferSize, MUFFT_FLAG_CPU_ANY); - mufft_execute_plan_1d(plan, out, recentPCMSamples.data()); + auto in = static_cast(mufft_alloc(recentPCMSamplesBufferSize * sizeof(float))); + copy(recentPCMSamples.begin(), recentPCMSamples.begin() + recentPCMSamplesBufferSize, in); + mufft_execute_plan_1d(plan, out, in); mufft_free_plan_1d(plan); + mufft_free(in); copy(pBuffer, until, back_inserter(recentPCMSamples)); recentPCMSamples.clear(); pendingPlayBackCall = true;