From 06bfbbf15d236c57e9417f09644acd06d584ee93 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Wed, 10 Jul 2024 06:17:15 -0700 Subject: [PATCH] Make BUF_SIZE constexpr --- src/RageSoundMixBuffer.cpp | 7 ++----- src/RageSoundMixBuffer.h | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/RageSoundMixBuffer.cpp b/src/RageSoundMixBuffer.cpp index 99d1081284..6bf9cf53b6 100644 --- a/src/RageSoundMixBuffer.cpp +++ b/src/RageSoundMixBuffer.cpp @@ -8,14 +8,11 @@ RageSoundMixBuffer::RageSoundMixBuffer() { - // See how many samples we can stuff into 2MB. - size_t BUF_SIZE = 2 * 1024 * 1024 / sizeof(float); - m_pMixbuf = static_cast(std::malloc(BUF_SIZE * sizeof(float))); - if (m_pMixbuf == nullptr) { + if (m_pMixbuf == nullptr) + { ASSERT_M(false, "Failed to allocate memory for the sound mixing buffer"); } - m_iBufSize = BUF_SIZE; std::memset(m_pMixbuf, 0, m_iBufSize * sizeof(float)); m_iBufUsed = 0; diff --git a/src/RageSoundMixBuffer.h b/src/RageSoundMixBuffer.h index 0f47e377fc..0eba9b62fd 100644 --- a/src/RageSoundMixBuffer.h +++ b/src/RageSoundMixBuffer.h @@ -11,6 +11,9 @@ public: RageSoundMixBuffer(); ~RageSoundMixBuffer(); + // See how many samples we can stuff into 2MB. + static constexpr size_t BUF_SIZE = 2 * 1024 * 1024 / sizeof(float); + // Mix the given buffer of samples. void write( const float *pBuf, unsigned iSize, int iSourceStride = 1, int iDestStride = 1 );