Volumes sliders in settings now use hardware volumes and doesn't use internal software gains anymore.

This commit is contained in:
Julien Wadel 2025-05-07 15:30:03 +02:00
parent 1f96259c16
commit 1c8f5da470
5 changed files with 37 additions and 18 deletions

View file

@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Timezones and Windows fix.
- Download the correct version of openH264 (2.2.0)
- Avoid to register the account while activating it.
- Update SDK to 5.3.80
- Volumes settings based on hardware volumes. Remove software gains.
### Added
- Screen Sharing

View file

@ -297,6 +297,10 @@ void CoreManager::createLinphoneCore (const QString &configPath) {
}
if( mCore->getAccountList().size() == 0)
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
// These 2 API should not be used because they are only software and manage internal gains.
// Functions from 'Call' object or from the CaptureGraph must be used in order to impact the system volume.
mCore->setMicGainDb(0.0);
mCore->setPlaybackGainDb(0.0);
}
void CoreManager::updateUserAgent(){

View file

@ -410,37 +410,50 @@ bool SettingsModel::getCaptureGraphRunning() {
return mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning() && !getIsInCall();
}
float SettingsModel::getMicVolume() {
float SettingsModel::getPlaybackGain() const {
float v = 0.0;
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
v = mSimpleCaptureGraph->getCaptureVolume();
v = mSimpleCaptureGraph->getPlaybackGain();
}else{
auto call = CoreManager::getInstance()->getCore()->getCurrentCall();
if (call) v = call->getSpeakerVolumeGain();
}
return v;
}
float SettingsModel::getPlaybackGain() const {
float dbGain = CoreManager::getInstance()->getCore()->getPlaybackGainDb();
return MediastreamerUtils::dbToLinear(dbGain);
}
void SettingsModel::setPlaybackGain(float gain) {
float oldGain = getPlaybackGain();
CoreManager::getInstance()->getCore()->setPlaybackGainDb(MediastreamerUtils::linearToDb(gain));
auto call = CoreManager::getInstance()->getCore()->getCurrentCall();
if (call) call->setSpeakerVolumeGain(gain);
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
mSimpleCaptureGraph->setPlaybackGain(gain);
}
if ((int)(oldGain * 1000) != (int)(gain * 1000)) emit playbackGainChanged(gain);
}
float SettingsModel::getMicVolume() const {
float v = 0.0;
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning())
v = mSimpleCaptureGraph->getCaptureVolume();
return v;
}
float SettingsModel::getCaptureGain() const {
float dbGain = CoreManager::getInstance()->getCore()->getMicGainDb();
return MediastreamerUtils::dbToLinear(dbGain);
float v = 0.0;
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
v = mSimpleCaptureGraph->getCaptureGain();
}else{
auto call = CoreManager::getInstance()->getCore()->getCurrentCall();
if (call) v = call->getMicrophoneVolumeGain();
}
return v;
}
void SettingsModel::setCaptureGain(float gain) {
float oldGain = getCaptureGain();
CoreManager::getInstance()->getCore()->setMicGainDb(MediastreamerUtils::linearToDb(gain));
auto call = CoreManager::getInstance()->getCore()->getCurrentCall();
if (call) call->setMicrophoneVolumeGain(gain);
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
mSimpleCaptureGraph->setCaptureGain(gain);
}

View file

@ -382,7 +382,7 @@ public:
void accessAudioSettings();
void closeAudioSettings();
Q_INVOKABLE float getMicVolume();
Q_INVOKABLE float getMicVolume() const; // Get realtime microphone volume
float getPlaybackGain() const;
void setPlaybackGain(float gain);

View file

@ -70,15 +70,16 @@ TabContainer {
id: playbackSlider
width: parent.width
enabled: !SettingsModel.isInCall
value: SettingsModel.playbackGain
onPositionChanged: SettingsModel.playbackGain = position
onVisibleChanged: value = SettingsModel.playbackGain
ToolTip {
parent: playbackSlider.handle
visible: playbackSlider.pressed
text: (playbackSlider.value * 100).toFixed(0) + " %"
}
Component.onCompleted: value = SettingsModel.playbackGain
}
}
}
@ -106,15 +107,16 @@ TabContainer {
id: captureSlider
width: parent.width
enabled: !SettingsModel.isInCall
value: SettingsModel.captureGain
onPositionChanged: SettingsModel.captureGain = position
onVisibleChanged: value = SettingsModel.captureGain
ToolTip {
parent: captureSlider.handle
visible: captureSlider.pressed
text: (captureSlider.value * 100).toFixed(0) + " %"
}
Component.onCompleted: value = SettingsModel.captureGain
}
}
}