diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-07-15 22:50:02 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-07-16 20:06:41 +0300 |
| commit | 8aa0161ed3f370a37a4ae849ce5c8a367d88c3fb (patch) | |
| tree | bd8cdad3be840ff2dd8a112909d02d77a0fdf98c | |
| parent | b76dce8903f9fd653ab604132c79c091c5476b08 (diff) | |
#6002 Filter out inaudible media volume changes
| -rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 10 | ||||
| -rw-r--r-- | indra/llplugin/llpluginmessagepipe.cpp | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index 4e80f4c0ca..94c29d9457 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -33,6 +33,8 @@ #include "llpluginmessageclasses.h" #include "llcontrol.h" +#include <cmath> + extern LLControlGroup gSavedSettings; #if LL_DARWIN extern bool gHiDPISupport; @@ -1616,7 +1618,13 @@ void LLPluginClassMedia::setLoop(bool loop) void LLPluginClassMedia::setVolume(float volume) { - if(volume != mRequestedVolume) + // VLC's volume is integer, 0 to 100 range. When converted from float, + // changes below 0.01 won't be noticed by VLC. + // CEF's audio range is DWORD, 0 to 65535. But changes so small are + // inaudible and don't warrant the overhead, so use a bigger epsilon + // to avoid extra messages and locking. + constexpr float VOLUME_EPSILON = 0.002f; + if (std::abs(volume - mRequestedVolume) > VOLUME_EPSILON) { mRequestedVolume = volume; diff --git a/indra/llplugin/llpluginmessagepipe.cpp b/indra/llplugin/llpluginmessagepipe.cpp index 085afc0944..1e58e6c49b 100644 --- a/indra/llplugin/llpluginmessagepipe.cpp +++ b/indra/llplugin/llpluginmessagepipe.cpp @@ -121,8 +121,9 @@ bool LLPluginMessagePipe::addMessage(const std::string &message) mOutputStartIndex = 0; } + mOutput.reserve(mOutput.size() + message.size() + 1); mOutput += message; - mOutput += MESSAGE_DELIMITER; // message separator + mOutput.push_back(MESSAGE_DELIMITER); // message separator return true; } |
