fix #LINQT-1657 do not manipulate internal gains

This commit is contained in:
Gaelle Braud 2025-05-14 10:06:07 +02:00
parent fb786c2a9d
commit 490f5cdca1
4 changed files with 44 additions and 17 deletions

View file

@ -206,6 +206,13 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
mustBeInLinphoneThread(getClassName());
mSettingsModelConnection = SafeConnection<SettingsCore, SettingsModel>::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); });

View file

@ -411,7 +411,7 @@ void CallModel::onStateChanged(const std::shared_ptr<linphone::Call> &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();

View file

@ -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<MagicSearchModel>(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);
}
//---------------------------------------------------------------------------------------------------------------------------

View file

@ -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);
}