From c9c86bd9aa133e04b039a422cefec43fec96dd8b Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Wed, 27 Sep 2023 17:00:31 +0200 Subject: [PATCH] sound/pipewire: move stream_hash insert into lock Inserting a new stream into stream_hash can potentially move out of context a stream previously stored in the hash with the same id, triggering pw::stream::Stream::Drop, which calls pw_stream_destroy. As calls to the pipewire library must happen either in the pipewire thread or under thread_loop lock protection, move the insert into stream_hash under the latter. Signed-off-by: Sergio Lopez --- crates/sound/src/audio_backends/pipewire.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sound/src/audio_backends/pipewire.rs b/crates/sound/src/audio_backends/pipewire.rs index 8748e8e..0c8e61a 100644 --- a/crates/sound/src/audio_backends/pipewire.rs +++ b/crates/sound/src/audio_backends/pipewire.rs @@ -385,10 +385,10 @@ impl AudioBackend for PwBackend { ) .expect("could not connect to the stream"); - lock_guard.unlock(); - // insert created stream in a hash table stream_hash.insert(stream_id, stream); + + lock_guard.unlock(); } Ok(())