From 848c63e2d55130c4e2ed3f3ef71ed9ea99a8bdba Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Sun, 4 Aug 2019 20:24:51 +0200
Subject: [PATCH] output/jack: use std::atomic_bool for "shutdown" and "pause"

Without this, the compiler may optimize accesses away.
---
 src/output/plugins/JackOutputPlugin.cxx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx
index 5b7a2fe2e..9204e9c1f 100644
--- a/src/output/plugins/JackOutputPlugin.cxx
+++ b/src/output/plugins/JackOutputPlugin.cxx
@@ -28,6 +28,8 @@
 #include "util/Domain.hxx"
 #include "Log.hxx"
 
+#include <atomic>
+
 #include <assert.h>
 
 #include <jack/jack.h>
@@ -69,13 +71,13 @@ struct JackOutput final : AudioOutput {
 	jack_client_t *client;
 	jack_ringbuffer_t *ringbuffer[MAX_PORTS];
 
-	bool shutdown;
+	std::atomic_bool shutdown;
 
 	/**
 	 * While this flag is set, the "process" callback generates
 	 * silence.
 	 */
-	bool pause;
+	std::atomic_bool pause;
 
 	explicit JackOutput(const ConfigBlock &block);