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: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1402>
This commit is contained in:
Sebastian Dröge 2024-02-21 12:09:14 +02:00
parent 62973fc83c
commit 7cc1f6cd45

View file

@ -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