From 6aa9751d201e533a988b06033b5d0945a775317c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 12 Apr 2023 13:58:47 -0400
Subject: [PATCH] libjami: respect LIBJAMI_FLAG_NO_LOCAL_AUDIO

Change-Id: Ic7044e0aaef48403ab879750f43da202bbee21e0
---
 src/manager.cpp  | 4 ++--
 src/manager.h    | 2 +-
 src/ring_api.cpp | 5 ++++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/manager.cpp b/src/manager.cpp
index c784db74cc..3867e06e61 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -743,7 +743,7 @@ Manager::setAutoAnswer(bool enable)
 }
 
 void
-Manager::init(const std::string& config_file)
+Manager::init(const std::string& config_file, libjami::InitFlag flags)
 {
     // FIXME: this is no good
     initialized = true;
@@ -841,7 +841,7 @@ Manager::init(const std::string& config_file)
         }
     }
 
-    {
+    if (!(flags & libjami::LIBJAMI_FLAG_NO_LOCAL_AUDIO)) {
         std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_);
         pimpl_->initAudioDriver();
         if (pimpl_->audiodriver_) {
diff --git a/src/manager.h b/src/manager.h
index d3de5ebbf6..a7fea1e11a 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -125,7 +125,7 @@ public:
      * Initialisation of thread (sound) and map.
      * Init a new VoIPLink, audio codec and audio driver
      */
-    void init(const std::string& config_file);
+    void init(const std::string& config_file, libjami::InitFlag flags);
 
     /*
      * Terminate all threads and exit DBus loop
diff --git a/src/ring_api.cpp b/src/ring_api.cpp
index b51423c235..74a94da5fb 100644
--- a/src/ring_api.cpp
+++ b/src/ring_api.cpp
@@ -41,9 +41,12 @@
 
 namespace libjami {
 
+InitFlag initFlags = {};
+
 bool
 init(enum InitFlag flags) noexcept
 {
+    initFlags = flags;
     jami::Logger::setDebugMode(LIBJAMI_FLAG_DEBUG == (flags & LIBJAMI_FLAG_DEBUG));
 
     jami::Logger::setSysLog(true);
@@ -82,7 +85,7 @@ bool
 start(const std::string& config_file) noexcept
 {
     try {
-        jami::Manager::instance().init(config_file);
+        jami::Manager::instance().init(config_file, initFlags);
     } catch (...) {
         return false;
     }
-- 
GitLab