This commit is contained in:
Kae 2023-07-15 00:39:10 +10:00
parent b4a53e0706
commit 91cd6182d8

View File

@ -380,6 +380,14 @@ bool Voice::receive(SpeakerPtr speaker, std::string_view view) {
{ {
MutexLocker lock(speaker->audioStream->mutex); MutexLocker lock(speaker->audioStream->mutex);
auto& samples = speaker->audioStream->samples; auto& samples = speaker->audioStream->samples;
if (mono) {
size_t prevSize = samples.size();
samples.resize(prevSize + (size_t)decodedSamples * 2);
int16_t* data = samples.data() + prevSize;
for (int i = 0; i != decodedSamples; ++i)
*data++ = *data++ = decodeBuffer[i];
}
else
samples.insert(samples.end(), decodeBuffer, decodeBuffer + decodedSamples); samples.insert(samples.end(), decodeBuffer, decodeBuffer + decodedSamples);
} }
playSpeaker(speaker, channels); playSpeaker(speaker, channels);