From 848b11399f2e34d7f1e0523e214287bfdcc5816c Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sun, 16 Jul 2023 23:04:09 +1000 Subject: Get SE-compatible voice transmission working --- source/frontend/StarVoice.cpp | 5 +++-- source/frontend/StarVoice.hpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source/frontend') diff --git a/source/frontend/StarVoice.cpp b/source/frontend/StarVoice.cpp index 4c0f4be..c6ec1d0 100644 --- a/source/frontend/StarVoice.cpp +++ b/source/frontend/StarVoice.cpp @@ -269,7 +269,6 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) { speaker->decibelLevel = getAudioLoudness(speakerBuffer.data(), samples); auto channelVolumes = speaker->channelVolumes.load(); - for (size_t i = 0; i != samples; ++i) sharedBuffer[i] += (int32_t)(speakerBuffer[i]) * channelVolumes[i % 2]; } @@ -366,6 +365,8 @@ bool Voice::receive(SpeakerPtr speaker, std::string_view view) { uint32_t opusLength = 0; while (!reader.atEnd()) { reader >> opusLength; + if (reader.pos() + opusLength > reader.size()) + throw VoiceException("Opus packet length goes past end of buffer"s, false); auto opusData = (unsigned char*)reader.ptr() + reader.pos(); reader.seek(opusLength, IOSeek::Relative); @@ -536,7 +537,7 @@ void Voice::thread() { { MutexLocker lock(m_encodeMutex); - m_encodedChunks.emplace_back(move(encoded)); // reset takes ownership of data buffer + m_encodedChunks.emplace_back(move(encoded)); m_encodedChunksLength += encodedSize; encoded = ByteArray(VOICE_MAX_PACKET_SIZE, 0); diff --git a/source/frontend/StarVoice.hpp b/source/frontend/StarVoice.hpp index 3b95235..38964b0 100644 --- a/source/frontend/StarVoice.hpp +++ b/source/frontend/StarVoice.hpp @@ -171,7 +171,7 @@ private: int64_t m_lastThresholdTime = 0; int64_t m_nextSaveTime = 0; bool m_enabled = true; - bool m_inputEnabled = true; + bool m_inputEnabled = false; int m_deviceChannels = 1; bool m_deviceOpen = false; -- cgit v1.2.3