diff --git a/linphone-app/src/components/calls/CallsListModel.cpp b/linphone-app/src/components/calls/CallsListModel.cpp index fb069d5fd..f11abb91f 100644 --- a/linphone-app/src/components/calls/CallsListModel.cpp +++ b/linphone-app/src/components/calls/CallsListModel.cpp @@ -93,6 +93,7 @@ void CallsListModel::askForAttendedTransfer (CallModel *callModel) { // ----------------------------------------------------------------------------- void CallsListModel::launchAudioCall (const QString &sipAddress, const QString& prepareTransfertAddress, const QHash &headers) const { + CoreManager::getInstance()->getSettingsModel()->stopCaptureGraphs(); CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true; shared_ptr 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 &headers, const QString& prepareTransfertAddress) const { + CoreManager::getInstance()->getSettingsModel()->stopCaptureGraphs(); CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = true; shared_ptr 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 core = CoreManager::getInstance()->getCore(); if (!CoreManager::getInstance()->getSettingsModel()->getVideoEnabled()) { diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index d0ac4fe5c..01397b450 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -343,10 +343,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 ){ @@ -354,7 +355,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(); @@ -374,9 +381,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() { @@ -2054,11 +2062,15 @@ void SettingsModel::setDeveloperSettingsEnabled (bool status) { } void SettingsModel::handleCallCreated(const shared_ptr &) { - 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::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); diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 0d4f35821..115378273 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -335,7 +335,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(); diff --git a/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml b/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml index c695e77e2..3732d9f87 100644 --- a/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml +++ b/linphone-app/ui/modules/Linphone/Dialog/MultimediaParametersDialog.qml @@ -37,7 +37,8 @@ DialogPlus { Component.onCompleted: { SettingsModel.stopCaptureGraph() SettingsModel.reloadDevices() - SettingsModel.startCaptureGraph() + if(!call) + SettingsModel.startCaptureGraph() if( fixedSize){ height = fitHeight width = fitWidth diff --git a/linphone-app/ui/views/App/Settings/SettingsAudio.qml b/linphone-app/ui/views/App/Settings/SettingsAudio.qml index 8e1d8829b..ce7e81d77 100644 --- a/linphone-app/ui/views/App/Settings/SettingsAudio.qml +++ b/linphone-app/ui/views/App/Settings/SettingsAudio.qml @@ -320,4 +320,8 @@ TabContainer { } } } + Connections{ + target: SettingsModel + onIsInCall: if(!SettingsModel.isInCall) SettingsModel.startCaptureGraph() + } }