From 96205687c514c0440739e3f5cf900998df3244de Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 17 Dec 2018 13:27:27 +0100 Subject: [PATCH] stream: make sure we have a context Make sure we ref the stream because else it would be freed when disconnected and we can't get the context anymore. --- src/stream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stream.c b/src/stream.c index 281d07816..ef74f3fa0 100644 --- a/src/stream.c +++ b/src/stream.c @@ -970,19 +970,23 @@ static void on_disconnected(pa_operation *o, void *userdata) int pa_stream_disconnect(pa_stream *s) { pa_operation *o; + pa_context *c = s->context; spa_assert(s); spa_assert(s->refcount >= 1); - PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); + PA_CHECK_VALIDITY(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); pw_log_debug("stream %p: disconnect", s); + pa_stream_ref(s); s->disconnecting = true; pw_stream_disconnect(s->stream); - o = pa_operation_new(s->context, s, on_disconnected, 0); + + o = pa_operation_new(c, s, on_disconnected, 0); pa_operation_sync(o); pa_operation_unref(o); + pa_stream_unref(s); return 0; }