From 52ba6fa7f78269fb69bb3addb297b6a8d0a779fd Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:44:13 +1000 Subject: [PATCH] Ensure NONTHREADSAFE_PSUEDOSTACK is never used --- source/CMakeLists.txt | 2 +- source/extern/CMakeLists.txt | 9 ++++++++- source/frontend/StarVoice.cpp | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 4f44bc2..e71ba21 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -437,7 +437,7 @@ SET (STAR_EXT_LIBS ${STAR_EXT_LIBS} ${FREETYPE_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} - "extern/opus/opus" + opus ) IF (STAR_BUILD_GUI) diff --git a/source/extern/CMakeLists.txt b/source/extern/CMakeLists.txt index f2e670c..2e4ea24 100644 --- a/source/extern/CMakeLists.txt +++ b/source/extern/CMakeLists.txt @@ -2,10 +2,17 @@ SET (OPUS_INSTALL_PKG_CONFIG_MODULE OFF) SET (OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF) SET (OPUS_X86_MAY_HAVE_AVX OFF) SET (OPUS_X86_MAY_HAVE_SSE4_1 OFF) -SET (OPUS_STACK_PROTECTOR OFF) SET (OPUS_ENABLE_FLOAT_API ON) +SET (OPUS_STACK_PROTECTOR OFF) +SET (OPUS_NONTHREADSAFE_PSEUDOSTACK OFF) +SET (OPUS_USE_ALLOCA ON) + ADD_SUBDIRECTORY (opus) +IF (OPUS_NONTHREADSAFE_PSEUDOSTACK) + MESSAGE (FATAL_ERROR "Opus should not be using NONTHREADSAFE_PSEUDOSTACK") +ENDIF () + INCLUDE_DIRECTORIES ( ${STAR_EXTERN_INCLUDES} opus/include diff --git a/source/frontend/StarVoice.cpp b/source/frontend/StarVoice.cpp index 4f9051b..dc97070 100644 --- a/source/frontend/StarVoice.cpp +++ b/source/frontend/StarVoice.cpp @@ -250,9 +250,9 @@ void Voice::readAudioData(uint8_t* stream, int len) { ByteArray encoded(VOICE_MAX_PACKET_SIZE, 0); size_t frameSamples = VOICE_FRAME_SIZE * (size_t)m_deviceChannels; - std::vector samples; - samples.reserve(frameSamples); while (m_capturedChunksFrames >= VOICE_FRAME_SIZE) { + std::vector samples; + samples.reserve(frameSamples); size_t samplesLeft = frameSamples; while (samplesLeft && !m_capturedChunks.empty()) { auto& front = m_capturedChunks.front();