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

View File

@ -380,7 +380,15 @@ bool Voice::receive(SpeakerPtr speaker, std::string_view view) {
{
MutexLocker lock(speaker->audioStream->mutex);
auto& samples = speaker->audioStream->samples;
samples.insert(samples.end(), decodeBuffer, decodeBuffer + decodedSamples);
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);
}
playSpeaker(speaker, channels);
}