Fix capture graph listener count: count all cases where the capture graph is needed.
Fix avoiding to have a call and a graph both: - If in call or new call, switch off the capture graph and to not create new graphs. - If not in call or no more call, switch on the capture graph if needed (listener count > 0). - Return volume result to GUI from the capture graph or the current call.
This commit is contained in:
parent
727c53209b
commit
3e57429534
1 changed files with 47 additions and 34 deletions
|
|
@ -62,6 +62,13 @@ SettingsModel::SettingsModel() {
|
||||||
notifyConfigReady();
|
notifyConfigReady();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Media cards must not be used twice (capture card + call) else we will get latencies issues and bad echo
|
||||||
|
// calibrations in call.
|
||||||
|
QObject::connect(CoreModel::getInstance().get(), &CoreModel::firstCallStarted, this,
|
||||||
|
[this]() { deleteCaptureGraph(); });
|
||||||
|
QObject::connect(CoreModel::getInstance().get(), &CoreModel::lastCallEnded, this, [this]() {
|
||||||
|
if (mCaptureGraphListenerCount > 0) createCaptureGraph(); // Repair the capture graph
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsModel::~SettingsModel() {
|
SettingsModel::~SettingsModel() {
|
||||||
|
|
@ -100,9 +107,12 @@ bool SettingsModel::getIsInCall() const {
|
||||||
|
|
||||||
void SettingsModel::resetCaptureGraph() {
|
void SettingsModel::resetCaptureGraph() {
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
deleteCaptureGraph();
|
if (mSimpleCaptureGraph) {
|
||||||
createCaptureGraph();
|
deleteCaptureGraph();
|
||||||
|
createCaptureGraph();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsModel::createCaptureGraph() {
|
void SettingsModel::createCaptureGraph() {
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
mSimpleCaptureGraph =
|
mSimpleCaptureGraph =
|
||||||
|
|
@ -111,32 +121,6 @@ void SettingsModel::createCaptureGraph() {
|
||||||
mSimpleCaptureGraph->start();
|
mSimpleCaptureGraph->start();
|
||||||
emit captureGraphRunningChanged(getCaptureGraphRunning());
|
emit captureGraphRunningChanged(getCaptureGraphRunning());
|
||||||
}
|
}
|
||||||
void SettingsModel::startCaptureGraph() {
|
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
|
||||||
if (!getIsInCall()) {
|
|
||||||
if (!mSimpleCaptureGraph) {
|
|
||||||
qDebug() << "Starting capture graph [" << mCaptureGraphListenerCount << "]";
|
|
||||||
createCaptureGraph();
|
|
||||||
}
|
|
||||||
++mCaptureGraphListenerCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void SettingsModel::stopCaptureGraph() {
|
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
|
||||||
if (mCaptureGraphListenerCount > 0) {
|
|
||||||
if (--mCaptureGraphListenerCount == 0) {
|
|
||||||
qDebug() << "Stopping capture graph [" << mCaptureGraphListenerCount << "]";
|
|
||||||
deleteCaptureGraph();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void SettingsModel::stopCaptureGraphs() {
|
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
|
||||||
if (mCaptureGraphListenerCount > 0) {
|
|
||||||
mCaptureGraphListenerCount = 0;
|
|
||||||
deleteCaptureGraph();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void SettingsModel::deleteCaptureGraph() {
|
void SettingsModel::deleteCaptureGraph() {
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
if (mSimpleCaptureGraph) {
|
if (mSimpleCaptureGraph) {
|
||||||
|
|
@ -147,6 +131,34 @@ void SettingsModel::deleteCaptureGraph() {
|
||||||
mSimpleCaptureGraph = nullptr;
|
mSimpleCaptureGraph = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void SettingsModel::stopCaptureGraphs() {
|
||||||
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
|
if (mCaptureGraphListenerCount > 0) {
|
||||||
|
mCaptureGraphListenerCount = 0;
|
||||||
|
deleteCaptureGraph();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsModel::startCaptureGraph() {
|
||||||
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
|
// Media cards must not be used twice (capture card + call) else we will get latencies issues and bad echo
|
||||||
|
// calibrations in call.
|
||||||
|
if (!getIsInCall() && !mSimpleCaptureGraph) {
|
||||||
|
qDebug() << log().arg("Starting capture graph [%1]").arg(mCaptureGraphListenerCount);
|
||||||
|
createCaptureGraph();
|
||||||
|
} else qDebug() << log().arg("Adding capture graph reference [%1]").arg(mCaptureGraphListenerCount);
|
||||||
|
++mCaptureGraphListenerCount;
|
||||||
|
}
|
||||||
|
void SettingsModel::stopCaptureGraph() {
|
||||||
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
|
if (--mCaptureGraphListenerCount == 0) {
|
||||||
|
qDebug() << log().arg("Stopping capture graph [%1]").arg(mCaptureGraphListenerCount);
|
||||||
|
deleteCaptureGraph();
|
||||||
|
} else if (mCaptureGraphListenerCount > 0)
|
||||||
|
qDebug() << log().arg("Removing capture graph reference [%1]").arg(mCaptureGraphListenerCount);
|
||||||
|
else qCritical() << log().arg("Removing too much capture graph reference [%1]").arg(mCaptureGraphListenerCount);
|
||||||
|
}
|
||||||
|
|
||||||
// Force a call on the 'detect' method of all audio filters, updating new or removed devices
|
// Force a call on the 'detect' method of all audio filters, updating new or removed devices
|
||||||
void SettingsModel::accessCallSettings() {
|
void SettingsModel::accessCallSettings() {
|
||||||
// Audio
|
// Audio
|
||||||
|
|
@ -161,12 +173,7 @@ void SettingsModel::accessCallSettings() {
|
||||||
emit playbackGainChanged(getPlaybackGain());
|
emit playbackGainChanged(getPlaybackGain());
|
||||||
emit captureGainChanged(getCaptureGain());
|
emit captureGainChanged(getCaptureGain());
|
||||||
|
|
||||||
// Media cards must not be used twice (capture card + call) else we will get latencies issues and bad echo
|
startCaptureGraph();
|
||||||
// calibrations in call.
|
|
||||||
if (!getIsInCall()) {
|
|
||||||
qDebug() << "Starting capture graph from accessing audio panel";
|
|
||||||
startCaptureGraph();
|
|
||||||
}
|
|
||||||
// Video
|
// Video
|
||||||
CoreModel::getInstance()->getCore()->reloadVideoDevices();
|
CoreModel::getInstance()->getCore()->reloadVideoDevices();
|
||||||
emit videoDevicesChanged(getVideoDevices());
|
emit videoDevicesChanged(getVideoDevices());
|
||||||
|
|
@ -189,7 +196,13 @@ float SettingsModel::getMicVolume() {
|
||||||
|
|
||||||
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
|
if (mSimpleCaptureGraph && mSimpleCaptureGraph->isRunning()) {
|
||||||
v = mSimpleCaptureGraph->getCaptureVolume();
|
v = mSimpleCaptureGraph->getCaptureVolume();
|
||||||
|
} else {
|
||||||
|
auto call = CoreModel::getInstance()->getCore()->getCurrentCall();
|
||||||
|
if (call) {
|
||||||
|
v = MediastreamerUtils::computeVu(call->getRecordVolume());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit micVolumeChanged(v);
|
emit micVolumeChanged(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue