From c0315bbc7117953fe5fa9b15f545f490cea2103d Mon Sep 17 00:00:00 2001 From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> Date: Thu, 20 Oct 2022 16:47:05 -0300 Subject: [PATCH] camera: fix closing - camera stays open after call with dbus - camera stays open after call to account on same device Change-Id: I2f2adf37b681009adfced6fe4d02d326b9408866 GitLab: #858 --- src/app/commoncomponents/LocalVideo.qml | 5 +++-- src/app/mainview/components/InitialCallPage.qml | 7 +++---- src/app/mainview/components/OngoingCallPage.qml | 5 ++--- src/app/mainview/components/SelectScreen.qml | 12 ++++++------ src/app/settingsview/components/VideoSettings.qml | 2 +- src/app/videodevices.cpp | 11 ++++------- src/app/videodevices.h | 4 ++-- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/app/commoncomponents/LocalVideo.qml b/src/app/commoncomponents/LocalVideo.qml index 3b7c43822..435ff9930 100644 --- a/src/app/commoncomponents/LocalVideo.qml +++ b/src/app/commoncomponents/LocalVideo.qml @@ -27,12 +27,13 @@ VideoView { crop: true - function startWithId(id, force = false) { + function startWithId(id) { if (id.length === 0) { VideoDevices.stopDevice(rendererId) rendererId = id } else { - rendererId = VideoDevices.startDevice(id, force) + if (rendererId !== id) + rendererId = VideoDevices.startDevice(id) } } } diff --git a/src/app/mainview/components/InitialCallPage.qml b/src/app/mainview/components/InitialCallPage.qml index c0f63732b..cf8dd9b0d 100644 --- a/src/app/mainview/components/InitialCallPage.qml +++ b/src/app/mainview/components/InitialCallPage.qml @@ -56,15 +56,14 @@ Rectangle { Timer { id: controlPreview property bool startVideo - interval: 1000; - running: false; - repeat: false + interval: 1000 onTriggered: { - var rendId = visible && start ? VideoDevices.getDefaultDevice() : "" + var rendId = visible && startVideo ? VideoDevices.getDefaultDevice() : "" previewRenderer.startWithId(rendId) } } onVisibleChanged: { + controlPreview.stop() if (visible) { controlPreview.startVideo = true controlPreview.interval = 1000 diff --git a/src/app/mainview/components/OngoingCallPage.qml b/src/app/mainview/components/OngoingCallPage.qml index 50064361a..5917cfa9e 100644 --- a/src/app/mainview/components/OngoingCallPage.qml +++ b/src/app/mainview/components/OngoingCallPage.qml @@ -211,14 +211,13 @@ Rectangle { id: controlPreview property bool startVideo interval: 1000 - running: false - repeat: false onTriggered: { - var rendId = visible && start ? root.callPreviewId : "" + var rendId = visible && startVideo ? root.callPreviewId : "" previewRenderer.startWithId(rendId) } } onVisibleChanged: { + controlPreview.stop() if (visible) { controlPreview.startVideo = true controlPreview.interval = 1000 diff --git a/src/app/mainview/components/SelectScreen.qml b/src/app/mainview/components/SelectScreen.qml index ce109c0f0..c3427120a 100644 --- a/src/app/mainview/components/SelectScreen.qml +++ b/src/app/mainview/components/SelectScreen.qml @@ -162,14 +162,14 @@ Window { Component.onDestruction: { if (rendererId !== "" && rendererId !== currentPreview) { - VideoDevices.stopDevice(rendererId, true) + VideoDevices.stopDevice(rendererId) } } Component.onCompleted: { if (visible) { const rId = AvAdapter.getSharingResource(index, "") if (rId !== "") { - rendererId = VideoDevices.startDevice(rId, true) + rendererId = VideoDevices.startDevice(rId) } } } @@ -234,14 +234,14 @@ Window { Component.onDestruction: { if (rendererId !== "" && rendererId !== currentPreview) { - VideoDevices.stopDevice(rendererId, true) + VideoDevices.stopDevice(rendererId) } } Component.onCompleted: { if (visible) { const rId = AvAdapter.getSharingResource(-1, "") if (rId !== "") { - rendererId = VideoDevices.startDevice(rId, true) + rendererId = VideoDevices.startDevice(rId) } } } @@ -314,14 +314,14 @@ Window { Component.onDestruction: { if (rendererId !== "" && rendererId !== currentPreview) { - VideoDevices.stopDevice(rendererId, true) + VideoDevices.stopDevice(rendererId) } } Component.onCompleted: { if (visible) { const rId = AvAdapter.getSharingResource(-2, AvAdapter.windowsIds[index - Qt.application.screens.length]) if (rId !== "") { - rendererId = VideoDevices.startDevice(rId, true) + rendererId = VideoDevices.startDevice(rId) } } } diff --git a/src/app/settingsview/components/VideoSettings.qml b/src/app/settingsview/components/VideoSettings.qml index 26aaa6189..fee9be760 100644 --- a/src/app/settingsview/components/VideoSettings.qml +++ b/src/app/settingsview/components/VideoSettings.qml @@ -40,7 +40,7 @@ ColumnLayout { if (!visible) { return } - previewWidget.startWithId(VideoDevices.getDefaultDevice(), force) + previewWidget.startWithId(VideoDevices.getDefaultDevice()) } onVisibleChanged: { diff --git a/src/app/videodevices.cpp b/src/app/videodevices.cpp index fe7c1251f..f872cc87a 100644 --- a/src/app/videodevices.cpp +++ b/src/app/videodevices.cpp @@ -236,25 +236,22 @@ VideoDevices::getDefaultDevice() } QString -VideoDevices::startDevice(const QString& id, bool force) +VideoDevices::startDevice(const QString& id) { if (id.isEmpty()) return {}; auto& avModel = lrcInstance_->avModel(); if (avModel.hasRenderer(id)) { - if (!force) { - return id; - } - avModel.stopPreview(id); + return id; } deviceOpen_ = true; return avModel.startPreview(id); } void -VideoDevices::stopDevice(const QString& id, bool force) +VideoDevices::stopDevice(const QString& id) { - if (!id.isEmpty() && (!lrcInstance_->hasActiveCall(true) || force)) { + if (!id.isEmpty()) { lrcInstance_->avModel().stopPreview(id); deviceOpen_ = false; } diff --git a/src/app/videodevices.h b/src/app/videodevices.h index aee88af88..0ab4d5afe 100644 --- a/src/app/videodevices.h +++ b/src/app/videodevices.h @@ -135,8 +135,8 @@ public: Q_INVOKABLE void setDefaultDevice(int index); Q_INVOKABLE const QString getDefaultDevice(); - Q_INVOKABLE QString startDevice(const QString& deviceId, bool force = false); - Q_INVOKABLE void stopDevice(const QString& deviceId, bool force = false); + Q_INVOKABLE QString startDevice(const QString& deviceId); + Q_INVOKABLE void stopDevice(const QString& deviceId); Q_INVOKABLE void setDefaultDeviceRes(int index); Q_INVOKABLE void setDefaultDeviceFps(int index); Q_INVOKABLE void setDisplayFPS(const QString& fps); -- GitLab