@@ -41,6 +41,10 @@ auto waybar::modules::MPD::update() -> void {
41
41
if (connection_ != nullptr) {
42
42
try {
43
43
bool wasPlaying = playing();
44
+ if(!wasPlaying) {
45
+ // Wait until the periodic_updater has stopped
46
+ std::lock_guard periodic_guard(periodic_lock_);
47
+ }
44
48
fetchState();
45
49
if (!wasPlaying && playing()) {
46
50
periodic_updater().detach();
@@ -75,6 +79,7 @@ std::thread waybar::modules::MPD::event_listener() {
75
79
76
80
std::thread waybar::modules::MPD::periodic_updater() {
77
81
return std::thread([this] {
82
+ std::lock_guard guard(periodic_lock_);
78
83
while (connection_ != nullptr && playing()) {
79
84
dp.emit();
80
85
std::this_thread::sleep_for(std::chrono::seconds(1));
@@ -297,7 +302,7 @@ void waybar::modules::MPD::waitForEvent() {
297
302
// Wait for a player (play/pause), option (random, shuffle, etc.), or playlist
298
303
// change
299
304
if (!mpd_send_idle_mask(
300
- conn, static_cast<mpd_idle>(MPD_IDLE_PLAYER | MPD_IDLE_OPTIONS | MPD_IDLE_PLAYLIST ))) {
305
+ conn, static_cast<mpd_idle>(MPD_IDLE_PLAYER | MPD_IDLE_OPTIONS | MPD_IDLE_QUEUE ))) {
301
306
checkErrors(conn);
302
307
return;
303
308
}
@@ -306,6 +311,10 @@ void waybar::modules::MPD::waitForEvent() {
306
311
// See issue #277:
307
312
// https://github.com/Alexays/Waybar/issues/277
308
313
mpd_recv_idle(conn, /* disable_timeout = */ false);
314
+ // See issue #281:
315
+ // https://github.com/Alexays/Waybar/issues/281
316
+ std::lock_guard guard(connection_lock_);
317
+
309
318
checkErrors(conn);
310
319
mpd_response_finish(conn);
311
320
0 commit comments