From 7cc1f6cd45bf5dc4a93e761fe31ce154f9d9abca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 21 Feb 2024 12:09:14 +0200 Subject: [PATCH] gstreamer: bus: Handle all previously queued messages too in the `BusStream` Before the stream was created, some messages might've been queued on the bus. For more similar behaviour with the bus watch, first pop all the queued messages before handling new messages. Part-of: --- gstreamer/src/bus.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 0775c896c..42181d043 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -346,7 +346,13 @@ impl BusStream { let (sender, receiver) = mpsc::unbounded(); - bus.set_sync_handler(move |_, message| { + bus.set_sync_handler(move |bus, message| { + // First pop all messages that might've been previously queued before creating + // the bus stream. + while let Some(message) = bus.pop() { + let _ = sender.unbounded_send(message); + } + let _ = sender.unbounded_send(message.to_owned()); BusSyncReply::Drop