[PATCH v3 0/1] MR723: winepulse.drv: Check state after connect
-- v3: winepulse: Use the predicate to terminate the connect cond_wait loop. https://gitlab.winehq.org/wine/wine/-/merge_requests/723
From: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> --- dlls/winepulse.drv/pulse.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 463f4c28d00..ea1332b9656 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -363,6 +363,8 @@ static BOOL pulse_stream_valid(struct pulse_stream *stream) static HRESULT pulse_connect(const char *name) { + pa_context_state_t state; + if (pulse_ctx && PA_CONTEXT_IS_GOOD(pa_context_get_state(pulse_ctx))) return S_OK; if (pulse_ctx) @@ -381,15 +383,12 @@ static HRESULT pulse_connect(const char *name) goto fail; /* Wait for connection */ - while (pulse_cond_wait()) { - pa_context_state_t state = pa_context_get_state(pulse_ctx); - - if (state == PA_CONTEXT_FAILED || state == PA_CONTEXT_TERMINATED) - goto fail; + while ((state = pa_context_get_state(pulse_ctx) != PA_CONTEXT_READY) && + state != PA_CONTEXT_FAILED && state != PA_CONTEXT_TERMINATED) + pulse_cond_wait(); - if (state == PA_CONTEXT_READY) - break; - } + if (state != PA_CONTEXT_READY) + goto fail; TRACE("Connected to server %s with protocol version: %i.\n", pa_context_get_server(pulse_ctx), -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/723
The second `)` on the `while` line is still in the wrong position. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/723#note_7296
participants (3)
-
Alistair Leslie-Hughes -
Alistair Leslie-Hughes (@alesliehughes) -
Huw Davies (@huw)