From 99c2a6ddc612f8c867c4c451e37602f0fd69ebe4 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 14 May 2025 10:06:07 +0200 Subject: [PATCH] fix #LINQT-1657 do not manipulate internal gains --- Linphone/core/setting/SettingsCore.cpp | 7 +++++ Linphone/model/core/CoreModel.cpp | 4 +++ Linphone/model/setting/SettingsModel.cpp | 33 +++++++++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index 77e22c786..8a489118a 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -237,6 +237,13 @@ void SettingsCore::setSelf(QSharedPointer me) { mustBeInLinphoneThread(getClassName()); mSettingsModelConnection = SafeConnection::create(me, SettingsModel::getInstance()); + mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureGraphRunningChanged, [this](bool running) { + mSettingsModelConnection->invokeToCore([this, running] { + mCaptureGraphRunning = running; + emit captureGraphRunningChanged(running); + }); + }); + // VFS mSettingsModelConnection->makeConnectToModel(&SettingsModel::vfsEnabledChanged, [this](const bool enabled) { mSettingsModelConnection->invokeToCore([this, enabled]() { setVfsEnabled(enabled); }); diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index f36550773..226d47c97 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -114,6 +114,10 @@ void CoreModel::start() { if (mCore->getLogCollectionUploadServerUrl().empty()) mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer); + /// These 2 API should not be used as they manage internal gains insterad of those of the soundcard. + // Use playback/capture gain from capture graph and call only + mCore->setMicGainDb(0.0); + mCore->setPlaybackGainDb(0.0); mIterateTimer = new QTimer(this); mIterateTimer->setInterval(20); connect(mIterateTimer, &QTimer::timeout, [this]() { mCore->iterate(); }); diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index a2bb672c5..79bd40b58 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -175,6 +175,7 @@ void SettingsModel::stopCaptureGraph() { void SettingsModel::accessCallSettings() { // Audio mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + startCaptureGraph(); CoreModel::getInstance()->getCore()->reloadSoundDevices(); emit captureDevicesChanged(getCaptureDevices()); emit playbackDevicesChanged(getPlaybackDevices()); @@ -185,7 +186,6 @@ void SettingsModel::accessCallSettings() { emit playbackGainChanged(getPlaybackGain()); emit captureGainChanged(getCaptureGain()); - startCaptureGraph(); // Video CoreModel::getInstance()->getCore()->reloadVideoDevices(); emit videoDevicesChanged(getVideoDevices()); @@ -205,13 +205,12 @@ bool SettingsModel::getCaptureGraphRunning() { float SettingsModel::getMicVolume() { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); float v = 0.0; - if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { v = mSimpleCaptureGraph->getCaptureVolume(); } else { auto call = CoreModel::getInstance()->getCore()->getCurrentCall(); if (call) { - v = MediastreamerUtils::computeVu(call->getRecordVolume()); + v = call->getRecordVolume(); } } @@ -221,33 +220,49 @@ float SettingsModel::getMicVolume() { float SettingsModel::getPlaybackGain() const { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - float dbGain = CoreModel::getInstance()->getCore()->getPlaybackGainDb(); - return MediastreamerUtils::dbToLinear(dbGain); + if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { + return mSimpleCaptureGraph->getPlaybackGain(); + } else { + auto call = CoreModel::getInstance()->getCore()->getCurrentCall(); + if (call) return call->getSpeakerVolumeGain(); + else return 0.0; + } } void SettingsModel::setPlaybackGain(float gain) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); float oldGain = getPlaybackGain(); - CoreModel::getInstance()->getCore()->setPlaybackGainDb(MediastreamerUtils::linearToDb(gain)); if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { mSimpleCaptureGraph->setPlaybackGain(gain); } + auto currentCall = CoreModel::getInstance()->getCore()->getCurrentCall(); + if (currentCall) { + currentCall->setSpeakerVolumeGain(gain); + } if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit playbackGainChanged(gain); } float SettingsModel::getCaptureGain() const { mustBeInLinphoneThread(getClassName()); - float dbGain = CoreModel::getInstance()->getCore()->getMicGainDb(); - return MediastreamerUtils::dbToLinear(dbGain); + if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { + return mSimpleCaptureGraph->getCaptureGain(); + } else { + auto call = CoreModel::getInstance()->getCore()->getCurrentCall(); + if (call) return call->getMicrophoneVolumeGain(); + else return 0.0; + } } void SettingsModel::setCaptureGain(float gain) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); float oldGain = getCaptureGain(); - CoreModel::getInstance()->getCore()->setMicGainDb(MediastreamerUtils::linearToDb(gain)); if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) { mSimpleCaptureGraph->setCaptureGain(gain); } + auto currentCall = CoreModel::getInstance()->getCore()->getCurrentCall(); + if (currentCall) { + currentCall->setMicrophoneVolumeGain(gain); + } if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit captureGainChanged(gain); }