From 024429ea7b9c1326579f88eef815612db40589d2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 27 Sep 2019 10:34:51 +0200 Subject: [PATCH] link: only set port io once Only set port_io once. Fixes #186 --- src/pipewire/link.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 99f250c30..71c620ecc 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -55,9 +55,10 @@ struct impl { struct pw_link this; - bool prepare; - bool activated; - bool passive; + unsigned int prepare:1; + unsigned int ioset:1; + unsigned int activated:1; + unsigned int passive:1; struct pw_work_queue *work; @@ -756,13 +757,16 @@ int pw_link_activate(struct pw_link *this) pw_link_prepare(this); - if ((res = port_set_io(this, this->output, SPA_IO_Buffers, this->io, - sizeof(struct spa_io_buffers), &this->rt.out_mix)) < 0) - return res; + if (!impl->ioset) { + if ((res = port_set_io(this, this->output, SPA_IO_Buffers, this->io, + sizeof(struct spa_io_buffers), &this->rt.out_mix)) < 0) + return res; - if ((res = port_set_io(this, this->input, SPA_IO_Buffers, this->io, - sizeof(struct spa_io_buffers), &this->rt.in_mix)) < 0) - return res; + if ((res = port_set_io(this, this->input, SPA_IO_Buffers, this->io, + sizeof(struct spa_io_buffers), &this->rt.in_mix)) < 0) + return res; + impl->ioset = true; + } if (this->info.state == PW_LINK_STATE_PAUSED) { pw_loop_invoke(this->output->node->data_loop, @@ -965,6 +969,7 @@ int pw_link_deactivate(struct pw_link *this) port_set_io(this, this->output, SPA_IO_Buffers, NULL, 0, &this->rt.out_mix); port_set_io(this, this->input, SPA_IO_Buffers, NULL, 0, &this->rt.in_mix); + impl->ioset = false; impl->activated = false; }