From e3d19993e9fb66f1b912a556549b77438211a544 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 14 Aug 2019 11:59:00 +0200 Subject: [PATCH] stream: EIO on format and buffers when disconnecting --- src/pipewire/stream.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 25ef09548..caa654641 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -546,8 +546,13 @@ static int impl_port_set_param(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param) { + struct stream *impl = object; + + if (impl->disconnecting) + return param == NULL ? 0 : -EIO; + if (id == SPA_PARAM_Format) { - return port_set_format(object, direction, port_id, flags, param); + return port_set_format(impl, direction, port_id, flags, param); } else return -ENOENT; @@ -622,6 +627,9 @@ static int impl_port_use_buffers(void *object, int prot, res; int size = 0; + if (impl->disconnecting) + return n_buffers == 0 ? 0 : -EIO; + prot = PROT_READ | (direction == SPA_DIRECTION_OUTPUT ? PROT_WRITE : 0); clear_buffers(stream); @@ -1437,6 +1445,7 @@ pw_stream_connect(struct pw_stream *stream, if ((res = find_format(impl, direction, &impl->media_type, &impl->media_subtype)) < 0) return res; + impl->disconnecting = false; stream_set_state(stream, PW_STREAM_STATE_CONNECTING, NULL); if (target_id != SPA_ID_INVALID)