diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index 88e4b45e8..e19ae31dd 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -206,6 +206,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/call/CallModel.cpp b/Linphone/model/call/CallModel.cpp index 4dd213edb..b007a199f 100644 --- a/Linphone/model/call/CallModel.cpp +++ b/Linphone/model/call/CallModel.cpp @@ -411,7 +411,7 @@ void CallModel::onStateChanged(const std::shared_ptr &call, emit localVideoEnabledChanged(videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv); emit remoteVideoEnabledChanged(remoteVideoDirection == linphone::MediaDirection::SendOnly || - remoteVideoDirection == linphone::MediaDirection::SendRecv); + remoteVideoDirection == linphone::MediaDirection::SendRecv); updateConferenceVideoLayout(); } else if (state == linphone::Call::State::End || state == linphone::Call::State::Error) { mDurationTimer.stop(); diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 357ae1f8b..e4b44375c 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -116,15 +116,19 @@ void CoreModel::start() { mCore->enableFriendListSubscription(true); 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->start(); auto linphoneSearch = mCore->createMagicSearch(); linphoneSearch->setLimitedSearch(true); mMagicSearch = Utils::makeQObject_ptr(linphoneSearch); mMagicSearch->setSelf(mMagicSearch); - connect(mMagicSearch.get(), &MagicSearchModel::searchResultsReceived, this, [this] { - emit magicSearchResultReceived(mMagicSearch->mLastSearch); - }); + connect(mMagicSearch.get(), &MagicSearchModel::searchResultsReceived, this, + [this] { emit magicSearchResultReceived(mMagicSearch->mLastSearch); }); } // ----------------------------------------------------------------------------- @@ -352,10 +356,11 @@ void CoreModel::migrate() { config->setInt(SettingsModel::UiSection, Constants::RcVersionName, Constants::RcVersionCurrent); } -void CoreModel::searchInMagicSearch(QString filter, int sourceFlags, - LinphoneEnums::MagicSearchAggregation aggregation, - int maxResults) { - mMagicSearch->search(filter, sourceFlags, aggregation, maxResults); +void CoreModel::searchInMagicSearch(QString filter, + int sourceFlags, + LinphoneEnums::MagicSearchAggregation aggregation, + int maxResults) { + mMagicSearch->search(filter, sourceFlags, aggregation, maxResults); } //--------------------------------------------------------------------------------------------------------------------------- diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index b6d74a53f..43f269f51 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -172,6 +172,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()); @@ -182,7 +183,6 @@ void SettingsModel::accessCallSettings() { emit playbackGainChanged(getPlaybackGain()); emit captureGainChanged(getCaptureGain()); - startCaptureGraph(); // Video CoreModel::getInstance()->getCore()->reloadVideoDevices(); emit videoDevicesChanged(getVideoDevices()); @@ -202,13 +202,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(); } } @@ -218,33 +217,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); }