From 7eb1e7373d48fa4c23f142b0b70c09f437d22e36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Sat, 31 Oct 2020 16:27:08 -0400
Subject: [PATCH] videomanager: don't start audio preview in switchInput

Change-Id: I820d008b9f437e4396f076fade34f3f9d9f8d053
---
 src/client/videomanager.cpp | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp
index 775acc1e24..6d96d8ea8d 100644
--- a/src/client/videomanager.cpp
+++ b/src/client/videomanager.cpp
@@ -457,8 +457,7 @@ startCamera()
 void
 stopCamera()
 {
-    if (switchInput(""))
-        jami::Manager::instance().getVideoManager().started = false;
+    jami::Manager::instance().getVideoManager().started = false;
     jami::Manager::instance().getVideoManager().videoPreview.reset();
 }
 
@@ -467,6 +466,7 @@ startAudioDevice()
 {
     jami::Manager::instance().getVideoManager().audioPreview = jami::getAudioInput(
         jami::RingBufferPool::DEFAULT_ID);
+    jami::Manager::instance().getVideoManager().audioPreview->switchInput("");
 }
 
 void
@@ -520,20 +520,13 @@ stopLocalRecorder(const std::string& filepath)
 bool
 switchInput(const std::string& resource)
 {
-    if (auto call = jami::Manager::instance().getCurrentCall()) {
-        if (call->hasVideo()) {
-            // TODO remove this part when clients are updated to use Calljami::Manager::switchInput
-            call->switchInput(resource);
-            return true;
-        }
-    }
     bool ret = true;
     if (auto input = jami::Manager::instance().getVideoManager().videoInput.lock())
         ret = input->switchInput(resource).valid();
     else
         JAMI_WARN("Video input not initialized");
 
-    if (auto input = jami::getAudioInput(jami::RingBufferPool::DEFAULT_ID))
+    if (auto input = jami::Manager::instance().getVideoManager().audioPreview)
         ret &= input->switchInput(resource).valid();
     return ret;
 }
-- 
GitLab