Do not reconnect if connection was refused

Otherwise, it will try to reconnect recursively
This commit is contained in:
Neltharion
2026-04-29 03:40:06 +03:00
parent cca8dc38b6
commit a66d6b1596
+10 -8
View File
@@ -99,15 +99,17 @@ void AudioBackend::contextStateCb(pa_context* c, void* data) {
nullptr, nullptr); nullptr, nullptr);
break; break;
case PA_CONTEXT_FAILED: case PA_CONTEXT_FAILED:
// When pulseaudio server restarts, the connection is "failed". Try to reconnect. if (pa_context_errno(c) != PA_ERR_CONNECTIONREFUSED) {
// pa_threaded_mainloop_lock is already acquired in callback threads. // When pulseaudio server restarts, the connection is "failed". Try to reconnect.
// So there is no need to lock it again. // pa_threaded_mainloop_lock is already acquired in callback threads.
if (backend->context_ != nullptr) { // So there is no need to lock it again.
pa_context_disconnect(backend->context_); if (backend->context_ != nullptr) {
pa_context_unref(backend->context_); pa_context_disconnect(backend->context_);
backend->context_ = nullptr; pa_context_unref(backend->context_);
backend->context_ = nullptr;
}
backend->connectContext();
} }
backend->connectContext();
break; break;
case PA_CONTEXT_CONNECTING: case PA_CONTEXT_CONNECTING:
case PA_CONTEXT_AUTHORIZING: case PA_CONTEXT_AUTHORIZING: