diff options
| -rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 48 | ||||
| -rw-r--r-- | indra/llwebrtc/llwebrtc_impl.h | 6 | ||||
| -rw-r--r-- | indra/newview/llconversationview.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llspeakingindicatormanager.cpp | 13 | ||||
| -rw-r--r-- | indra/newview/llviewermessage.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/llviewertexture.cpp | 26 | ||||
| -rw-r--r-- | indra/newview/llviewertexture.h | 1 | ||||
| -rw-r--r-- | indra/newview/llvocache.cpp | 6 | ||||
| -rw-r--r-- | indra/newview/llvoicechannel.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/llvoicechannel.h | 1 |
10 files changed, 71 insertions, 43 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index edba2bee9a..23e1076765 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -350,6 +350,16 @@ void LLWebRTCImpl::init() void LLWebRTCImpl::terminate() { + mWorkerThread->BlockingCall( + [this]() + { + if (mDeviceModule) + { + mDeviceModule->ForceStopRecording(); + mDeviceModule->StopPlayout(); + } + }); + for (auto &connection : mPeerConnections) { connection->terminate(); @@ -368,8 +378,6 @@ void LLWebRTCImpl::terminate() { if (mDeviceModule) { - mDeviceModule->StopRecording(); - mDeviceModule->StopPlayout(); mDeviceModule->Terminate(); } mDeviceModule = nullptr; @@ -442,11 +450,7 @@ void LLWebRTCImpl::unsetDevicesObserver(LLWebRTCDevicesObserver *observer) void LLWebRTCImpl::workerDeployDevices() { int16_t recordingDevice = RECORD_DEVICE_DEFAULT; -#if WEBRTC_WIN int16_t recording_device_start = 0; -#else - int16_t recording_device_start = 1; -#endif if (mRecordingDevice != "Default") { @@ -455,6 +459,12 @@ void LLWebRTCImpl::workerDeployDevices() if (mRecordingDeviceList[i].mID == mRecordingDevice) { recordingDevice = i; +#if !WEBRTC_WIN + // linux and mac devices range from 1 to the end of the list, with the index 0 being the + // 'default' device. Windows has a special 'default' device and other devices are indexed + // from 0 + recordingDevice++; +#endif break; } } @@ -479,11 +489,7 @@ void LLWebRTCImpl::workerDeployDevices() mDeviceModule->InitRecording(); int16_t playoutDevice = PLAYOUT_DEVICE_DEFAULT; -#if WEBRTC_WIN int16_t playout_device_start = 0; -#else - int16_t playout_device_start = 1; -#endif if (mPlayoutDevice != "Default") { for (int16_t i = playout_device_start; i < mPlayoutDeviceList.size(); i++) @@ -491,6 +497,12 @@ void LLWebRTCImpl::workerDeployDevices() if (mPlayoutDeviceList[i].mID == mPlayoutDevice) { playoutDevice = i; +#if !WEBRTC_WIN + // linux and mac devices range from 1 to the end of the list, with the index 0 being the + // 'default' device. Windows has a special 'default' device and other devices are indexed + // from 0 + playoutDevice++; +#endif break; } } @@ -546,20 +558,14 @@ void LLWebRTCImpl::workerDeployDevices() void LLWebRTCImpl::setCaptureDevice(const std::string &id) { - if (mRecordingDevice != id) - { - mRecordingDevice = id; - deployDevices(); - } + mRecordingDevice = id; + deployDevices(); } void LLWebRTCImpl::setRenderDevice(const std::string &id) { - if (mPlayoutDevice != id) - { - mPlayoutDevice = id; - deployDevices(); - } + mPlayoutDevice = id; + deployDevices(); } // updateDevices needs to happen on the worker thread. @@ -609,7 +615,7 @@ void LLWebRTCImpl::updateDevices() void LLWebRTCImpl::OnDevicesUpdated() { - deployDevices(); + updateDevices(); } diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 7b23b11208..6526c24f18 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -239,8 +239,10 @@ public: return 0; } int32_t StopRecording() override { - if (tuning_) return 0; // if we're tuning, disregard the StopRecording we get from disabling the streams - return inner_->StopRecording(); + // ignore stop recording as webrtc.lib will send one when streams shut down, + // even if there are other streams in place. Start/Stop recording are entirely + // controlled by the app + return 0; } int32_t ForceStartRecording() { return inner_->StartRecording(); } int32_t ForceStopRecording() { return inner_->StopRecording(); } diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp index 0e0ab236d6..99d770b6e2 100644 --- a/indra/newview/llconversationview.cpp +++ b/indra/newview/llconversationview.cpp @@ -543,7 +543,7 @@ void LLConversationViewSession::onCurrentVoiceSessionChanged(const LLUUID& sessi { bool old_value = mIsInActiveVoiceChannel; mIsInActiveVoiceChannel = vmi->getUUID() == session_id; - mCallIconLayoutPanel->setVisible(mIsInActiveVoiceChannel); + mCallIconLayoutPanel->setVisible(mIsInActiveVoiceChannel && !LLVoiceChannel::isSuspended()); if (old_value != mIsInActiveVoiceChannel) { refresh(); diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp index 532b245ced..06458a9f3c 100644 --- a/indra/newview/llspeakingindicatormanager.cpp +++ b/indra/newview/llspeakingindicatormanager.cpp @@ -200,8 +200,17 @@ void SpeakingIndicatorManager::cleanupSingleton() void SpeakingIndicatorManager::sOnCurrentChannelChanged(const LLUUID& /*session_id*/) { - switchSpeakerIndicators(mSwitchedIndicatorsOn, false); - mSwitchedIndicatorsOn.clear(); + if (LLVoiceChannel::isSuspended()) + { + switchSpeakerIndicators(mSwitchedIndicatorsOn, false); + mSwitchedIndicatorsOn.clear(); + } + else + { + // Multiple onParticipantsChanged can arrive at the same time + // from different sources, might want to filter by some factor. + onParticipantsChanged(); + } } void SpeakingIndicatorManager::onParticipantsChanged() diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 02171acaac..cd6cf869ae 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3386,13 +3386,10 @@ void send_agent_update(bool force_send, bool send_reliable) static F32 last_draw_disatance_step = 1024; F32 memory_limited_draw_distance = gAgentCamera.mDrawDistance; - if (LLViewerTexture::sDesiredDiscardBias > 2.f && LLViewerTexture::isSystemMemoryLow()) + if (LLViewerTexture::isSystemMemoryCritical()) { // If we are low on memory, reduce requested draw distance - // Discard's bias is clamped to 4 so we need to check 2 to 4 range - // Factor is intended to go from 1.0 to 2.0 - F32 factor = 1.f + (LLViewerTexture::sDesiredDiscardBias - 2.f) / 2.f; - memory_limited_draw_distance = llmax(gAgentCamera.mDrawDistance / factor, gAgentCamera.mDrawDistance / 2.f); + memory_limited_draw_distance = llmax(gAgentCamera.mDrawDistance / LLViewerTexture::getSystemMemoryBudgetFactor(), gAgentCamera.mDrawDistance / 2.f); } if (tp_state == LLAgent::TELEPORT_ARRIVING || LLStartUp::getStartupState() < STATE_MISC) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c50cd5083f..e40f109e55 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -657,23 +657,35 @@ U32Megabytes LLViewerTexture::getFreeSystemMemory() return physical_res; } -//static -bool LLViewerTexture::isSystemMemoryLow() +S32Megabytes get_render_free_main_memory_treshold() { static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); const U32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); - return getFreeSystemMemory() < MIN_FREE_MAIN_MEMORY; + return MIN_FREE_MAIN_MEMORY; +} + +//static +bool LLViewerTexture::isSystemMemoryLow() +{ + return getFreeSystemMemory() < get_render_free_main_memory_treshold(); +} + +//static +bool LLViewerTexture::isSystemMemoryCritical() +{ + return getFreeSystemMemory() < get_render_free_main_memory_treshold() / 2; } F32 LLViewerTexture::getSystemMemoryBudgetFactor() { - static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); - const S32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); + const S32Megabytes MIN_FREE_MAIN_MEMORY(get_render_free_main_memory_treshold() / 2); S32 free_budget = (S32Megabytes)getFreeSystemMemory() - MIN_FREE_MAIN_MEMORY; if (free_budget < 0) { - // Result should range from 1 (0 free budget) to 2 (-512 free budget) - return 1.f - free_budget / MIN_FREE_MAIN_MEMORY; + // Leave some padding, otherwise we will crash out of memory before hitting factor 2. + const S32Megabytes PAD_BUFFER(32); + // Result should range from 1 at 0 free budget to 2 at -224 free budget, 2.14 at -256MB + return 1.f - free_budget / (MIN_FREE_MAIN_MEMORY - PAD_BUFFER); } return 1.f; } diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index d32c302d8e..2937651995 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -115,6 +115,7 @@ public: static void initClass(); static void updateClass(); static bool isSystemMemoryLow(); + static bool isSystemMemoryCritical(); static F32 getSystemMemoryBudgetFactor(); LLViewerTexture(bool usemipmaps = true); diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ac73c2def6..52a6afc2d0 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -488,13 +488,11 @@ void LLVOCacheEntry::updateDebugSettings() static const F32 MIN_RADIUS = 1.0f; F32 draw_radius = gAgentCamera.mDrawDistance; - if (LLViewerTexture::sDesiredDiscardBias > 2.f && LLViewerTexture::isSystemMemoryLow()) + if (LLViewerTexture::isSystemMemoryCritical()) { - // Discard's bias maximum is 4 so we need to check 2 to 4 range // Factor is intended to go from 1.0 to 2.0 - F32 factor = 1.f + (LLViewerTexture::sDesiredDiscardBias - 2.f) / 2.f; // For safety cap reduction at 50%, we don't want to go below half of draw distance - draw_radius = llmax(draw_radius / factor, draw_radius / 2.f); + draw_radius = llmax(draw_radius / LLViewerTexture::getSystemMemoryBudgetFactor(), draw_radius / 2.f); } const F32 clamped_min_radius = llclamp((F32) min_radius, MIN_RADIUS, draw_radius); // [1, mDrawDistance] sNearRadius = MIN_RADIUS + ((clamped_min_radius - MIN_RADIUS) * adjust_factor); diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index b3ac28eb7a..fbe896ac27 100644 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -357,6 +357,8 @@ void LLVoiceChannel::suspend() { sSuspendedVoiceChannel = sCurrentVoiceChannel; sSuspended = true; + + sCurrentVoiceChannelChangedSignal(sSuspendedVoiceChannel->mSessionID); } } @@ -365,6 +367,7 @@ void LLVoiceChannel::resume() { if (sSuspended) { + sSuspended = false; // needs to be before activate() so that observers will be able to read state if (LLVoiceClient::getInstance()->voiceEnabled()) { if (sSuspendedVoiceChannel) @@ -382,7 +385,6 @@ void LLVoiceChannel::resume() LLVoiceChannelProximal::getInstance()->activate(); } } - sSuspended = false; } } diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index 4d7bf551e1..bf119638d3 100644 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -103,6 +103,7 @@ public: static void suspend(); static void resume(); + static bool isSuspended() { return sSuspended; } protected: virtual void setState(EState state); |
