From b9a2e8cde309cba96c7f14b401963732879a1896 Mon Sep 17 00:00:00 2001 From: mappu Date: Tue, 2 Oct 2018 20:21:24 +1300 Subject: [PATCH] qpulse: retry spawning mainloop thread --- qpulse.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/qpulse.cpp b/qpulse.cpp index 9e199f4..bbd5e37 100644 --- a/qpulse.cpp +++ b/qpulse.cpp @@ -6,7 +6,20 @@ QPulse::QPulse(QObject *parent) : ml(pa_threaded_mainloop_new()), c(nullptr) { - pa_threaded_mainloop_start(ml); + int start_retries = 5; + int err = -1; + for(; start_retries --> 0;) { + err = pa_threaded_mainloop_start(ml); + if (err == 0) { + break; + } + } + + // Fatal + if (err != 0) { + perror("pa_threaded_mainloop_start() failure\n"); + exit(EXIT_FAILURE); + } c = pa_context_new( pa_threaded_mainloop_get_api(ml), "pa-card-profile-tray"); pa_context_set_state_callback(c, &QPulse::onConnectionStateChangedSt, this);