Fix audio issues when using audio settings while being in call.

Media cards must not be used twice (capture card + call) else we will get latencies issues and bad echo calibrations in call.
Force to close all capture graph when going in call.
This commit is contained in:
Julien Wadel 2024-02-16 11:12:16 +01:00
parent d1fa93995f
commit d8e2a366d0
5 changed files with 32 additions and 11 deletions

View file

@ -93,6 +93,7 @@ void CallsListModel::askForAttendedTransfer (CallModel *callModel) {
// -----------------------------------------------------------------------------
void CallsListModel::launchAudioCall (const QString &sipAddress, const QString& prepareTransfertAddress, const QHash<QString, QString> &headers) const {
CoreManager::getInstance()->getSettingsModel()->stopCaptureGraphs();
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
@ -133,6 +134,7 @@ void CallsListModel::launchAudioCall (const QString &sipAddress, const QString&
}
void CallsListModel::launchSecureAudioCall (const QString &sipAddress, LinphoneEnums::MediaEncryption encryption, const QHash<QString, QString> &headers, const QString& prepareTransfertAddress) const {
CoreManager::getInstance()->getSettingsModel()->stopCaptureGraphs();
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true;
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
@ -172,6 +174,7 @@ void CallsListModel::launchSecureAudioCall (const QString &sipAddress, LinphoneE
}
void CallsListModel::launchVideoCall (const QString &sipAddress, const QString& prepareTransfertAddress, const bool& autoSelectAfterCreation, QVariantMap options) const {
CoreManager::getInstance()->getSettingsModel()->stopCaptureGraphs();
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = autoSelectAfterCreation;
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
if (!CoreManager::getInstance()->getSettingsModel()->getVideoEnabled()) {

View file

@ -332,10 +332,11 @@ void SettingsModel::createCaptureGraph() {
mSimpleCaptureGraph->start();
emit captureGraphRunningChanged(getCaptureGraphRunning());
}
void SettingsModel::startCaptureGraph(){
if(!mSimpleCaptureGraph)
createCaptureGraph();
++mCaptureGraphListenerCount;
void SettingsModel::startCaptureGraph() {
if(!getIsInCall()) {
if (!mSimpleCaptureGraph) createCaptureGraph();
++mCaptureGraphListenerCount;
}
}
void SettingsModel::stopCaptureGraph(){
if(mCaptureGraphListenerCount > 0 ){
@ -343,7 +344,13 @@ void SettingsModel::stopCaptureGraph(){
deleteCaptureGraph();
}
}
void SettingsModel::deleteCaptureGraph(){
void SettingsModel::stopCaptureGraphs() {
if (mCaptureGraphListenerCount > 0) {
mCaptureGraphListenerCount = 0;
deleteCaptureGraph();
}
}
void SettingsModel::deleteCaptureGraph() {
if (mSimpleCaptureGraph) {
if (mSimpleCaptureGraph->isRunning()) {
mSimpleCaptureGraph->stop();
@ -363,9 +370,10 @@ void SettingsModel::accessAudioSettings() {
emit playbackGainChanged(getPlaybackGain());
emit captureGainChanged(getCaptureGain());
//if (!getIsInCall()) {
// Media cards must not be used twice (capture card + call) else we will get latencies issues and bad echo calibrations in call.
if (!getIsInCall()) {
startCaptureGraph();
//}
}
}
void SettingsModel::closeAudioSettings() {
@ -2043,11 +2051,15 @@ void SettingsModel::setDeveloperSettingsEnabled (bool status) {
}
void SettingsModel::handleCallCreated(const shared_ptr<linphone::Call> &) {
emit isInCallChanged(getIsInCall());
bool isInCall = getIsInCall();
if(isInCall) stopCaptureGraphs(); // Ensure to stop all graphs
emit isInCallChanged(isInCall);
}
void SettingsModel::handleCallStateChanged(const shared_ptr<linphone::Call> &, linphone::Call::State) {
emit isInCallChanged(getIsInCall());
bool isInCall = getIsInCall();
if(isInCall) stopCaptureGraphs(); // Ensure to stop all graphs
emit isInCallChanged(isInCall);
}
void SettingsModel::handleEcCalibrationResult(linphone::EcCalibratorStatus status, int delayMs){
emit echoCancellationStatus((int)status, delayMs);

View file

@ -330,7 +330,8 @@ public:
// Audio. --------------------------------------------------------------------
Q_INVOKABLE void startCaptureGraph();
Q_INVOKABLE void stopCaptureGraph();
Q_INVOKABLE void stopCaptureGraph();;
Q_INVOKABLE void stopCaptureGraphs();
Q_INVOKABLE void resetCaptureGraph();
void createCaptureGraph();
void deleteCaptureGraph();

View file

@ -37,7 +37,8 @@ DialogPlus {
Component.onCompleted: {
SettingsModel.stopCaptureGraph()
SettingsModel.reloadDevices()
SettingsModel.startCaptureGraph()
if(!call)
SettingsModel.startCaptureGraph()
if( fixedSize){
height = fitHeight
width = fitWidth

View file

@ -320,4 +320,8 @@ TabContainer {
}
}
}
Connections{
target: SettingsModel
onIsInCall: if(!SettingsModel.isInCall) SettingsModel.startCaptureGraph()
}
}