qpulse: retry spawning mainloop thread

This commit is contained in:
mappu 2018-10-02 20:21:24 +13:00
parent 06c38bda9c
commit b9a2e8cde3
1 changed files with 14 additions and 1 deletions

View File

@ -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);