Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarVoice.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-16 23:04:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-16 23:04:09 +1000
commit848b11399f2e34d7f1e0523e214287bfdcc5816c (patch)
treea5ce3b996a7e02a18ee5660832f7b0b5643cd2a7 /source/frontend/StarVoice.cpp
parentda098c7b4812408d1316b14b3b3f46d2ec7dce04 (diff)
Get SE-compatible voice transmission working
Diffstat (limited to 'source/frontend/StarVoice.cpp')
-rw-r--r--source/frontend/StarVoice.cpp5
1 files changed, 3 insertions, 2 deletions
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);