From cc7be87b0e9c9114ca58f79979e31b8d7dbcd80c Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Date: Mon, 8 Mar 2021 13:38:07 -0500
Subject: [PATCH] audio: Do not prevent pulseaudio from autospawning a server.

This prevents downgrading the audio experience to ALSA on system
running a vanilla pulseaudio configuration that relies on pulseaudio
being able to manage the pulseaudio server itself.

* src/media/audio/pulseaudio/pulselayer.cpp (PulseLayer::PulseLayer)
[PA_CONTEXT_NOAUTOSPAWN]: Replace flags argument value with
PA_CONTEXT_NOFLAGS.
* src/media/audio/pulseaudio/pulselayer.h: Fix typo.

GitLab: #473
Change-Id: I219223dd8a1237a51b3e5bf60d6535518d748b63
---
 src/media/audio/pulseaudio/pulselayer.cpp | 2 +-
 src/media/audio/pulseaudio/pulselayer.h   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/media/audio/pulseaudio/pulselayer.cpp b/src/media/audio/pulseaudio/pulselayer.cpp
index a88dd85534..7c89ccbd86 100644
--- a/src/media/audio/pulseaudio/pulselayer.cpp
+++ b/src/media/audio/pulseaudio/pulselayer.cpp
@@ -87,7 +87,7 @@ PulseLayer::PulseLayer(AudioPreference& pref)
 
     pa_context_set_state_callback(context_, context_state_callback, this);
 
-    if (pa_context_connect(context_, nullptr, PA_CONTEXT_NOAUTOSPAWN, nullptr) < 0)
+    if (pa_context_connect(context_, nullptr, PA_CONTEXT_NOFLAGS, nullptr) < 0)
         throw std::runtime_error("Could not connect pulseaudio context to the server");
 
     // wait until context is ready
diff --git a/src/media/audio/pulseaudio/pulselayer.h b/src/media/audio/pulseaudio/pulselayer.h
index 61926583e4..0664ef1773 100644
--- a/src/media/audio/pulseaudio/pulselayer.h
+++ b/src/media/audio/pulseaudio/pulselayer.h
@@ -119,7 +119,8 @@ public:
     ~PulseLayer();
 
     /**
-     * Write data from the ring buffer to the harware and read data from the hardware
+     * Write data from the ring buffer to the hardware and read data
+     * from the hardware.
      */
     void readFromMic();
     void writeToSpeaker();
-- 
GitLab