Fix decibel level being 0 when under threshold

This commit is contained in:
Kae 2023-07-19 23:30:04 +10:00
parent 7ad1671e0d
commit db3d004d30

View File

@ -321,11 +321,12 @@ void Voice::readAudioData(uint8_t* stream, int len) {
}
}
m_clientSpeaker->decibelLevel = getAudioLoudness((int16_t*)stream, sampleCount, m_inputVolume);
if (!m_loopback) {
if (active && !m_clientSpeaker->playing)
m_clientSpeaker->lastPlayTime = now;
m_clientSpeaker->decibelLevel = getAudioLoudness((int16_t*)stream, sampleCount, m_inputVolume);
m_clientSpeaker->playing = active;
}
@ -366,6 +367,7 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) {
for (size_t i = 0; i != samples; ++i)
speakerBuffer[i] = audio->take();
if (speaker != m_clientSpeaker)
speaker->decibelLevel = getAudioLoudness(speakerBuffer.data(), samples);
float volume = speaker->volume;
@ -402,6 +404,7 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) {
}
else {
speaker->playing = false;
if (speaker != m_clientSpeaker)
speaker->decibelLevel = -96.0f;
it = m_activeSpeakers.erase(it);
}