From bb0f046a728bd30d4f157adb80bf791c5483d93e Mon Sep 17 00:00:00 2001 From: birarda Date: Thu, 15 Nov 2018 17:28:34 -0800 Subject: [PATCH] add throttle start and backoff to DS settings --- assignment-client/src/audio/AudioMixer.cpp | 15 ++++++++++----- assignment-client/src/audio/AudioMixer.h | 4 +++- domain-server/resources/describe-settings.json | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index d6f893c42e..5d203595c2 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -488,11 +488,8 @@ void AudioMixer::throttle(chrono::microseconds duration, int frame) { // target different mix and backoff ratios (they also have different backoff rates) // this is to prevent oscillation, and encourage throttling to find a steady state - const float TARGET = 0.9f; - // on a "regular" machine with 100 avatars, this is the largest value where - // - overthrottling can be recovered - // - oscillations will not occur after the recovery - const float BACKOFF_TARGET = 0.44f; + const float TARGET = _throttleStartTarget; + const float BACKOFF_TARGET = _throttleBackoffTarget; // the mixer is known to struggle at about 80 on a "regular" machine // so throttle 2/80 the streams to ensure smooth audio (throttling is linear) @@ -551,6 +548,14 @@ void AudioMixer::parseSettingsObject(const QJsonObject& settingsObject) { _slavePool.setNumThreads(numThreads); } } + + const QString THROTTLE_START_KEY = "throttle_start"; + const QString THROTTLE_BACKOFF_KEY = "throttle_backoff"; + + _throttleStartTarget = audioThreadingGroupObject[THROTTLE_START_KEY].toDouble(_throttleStartTarget); + _throttleBackoffTarget = audioThreadingGroupObject[THROTTLE_BACKOFF_KEY].toDouble(_throttleBackoffTarget); + + qCDebug(audio) << "Throttle Start:" << _throttleStartTarget << "Throttle Backoff:" << _throttleBackoffTarget; } if (settingsObject.contains(AUDIO_BUFFER_GROUP_KEY)) { diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index b8ea0d5c58..c7726d2fea 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -144,11 +144,13 @@ private: static std::map _availableCodecs; static QStringList _codecPreferenceOrder; - static std::vector _audioZones; static std::vector _zoneSettings; static std::vector _zoneReverbSettings; + float _throttleStartTarget = 0.9f; + float _throttleBackoffTarget = 0.44f; + AudioMixerSlave::SharedData _workerSharedData; }; diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 5d1f725ab4..49023c9af8 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -1012,6 +1012,24 @@ "placeholder": "1", "default": "1", "advanced": true + }, + { + "name": "throttle_start", + "type": "double", + "label": "Throttle Start Target", + "help": "Target percentage of frame time to start throttling", + "placeholder": "0.9", + "default": 0.9, + "advanced": true + }, + { + "name": "throttle_backoff", + "type": "double", + "label": "Throttle Backoff Target", + "help": "Target percentage of frame time to backoff throttling", + "placeholder": "0.44", + "default": 0.44, + "advanced": true } ] },