mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 11:36:11 +08:00
pipewire connection: Show banner if disconnected
This commit is contained in:
@@ -61,12 +61,20 @@ pub(super) fn thread_main(
|
||||
let mainloop = MainLoop::new().expect("Failed to create mainloop");
|
||||
let context = Rc::new(Context::new(&mainloop).expect("Failed to create context"));
|
||||
let is_stopped = Rc::new(Cell::new(false));
|
||||
let mut is_connecting = false;
|
||||
|
||||
while !is_stopped.get() {
|
||||
// Try to connect
|
||||
let core = match context.connect(None) {
|
||||
Ok(core) => Rc::new(core),
|
||||
Err(_) => {
|
||||
if !is_connecting {
|
||||
is_connecting = true;
|
||||
gtk_sender
|
||||
.send(PipewireMessage::Connecting)
|
||||
.expect("Failed to send message");
|
||||
}
|
||||
|
||||
// If connection is failed, try to connect again in 200ms
|
||||
let interval = Some(Duration::from_millis(200));
|
||||
|
||||
@@ -93,6 +101,13 @@ pub(super) fn thread_main(
|
||||
}
|
||||
};
|
||||
|
||||
if is_connecting {
|
||||
is_connecting = false;
|
||||
gtk_sender
|
||||
.send(PipewireMessage::Connected)
|
||||
.expect("Failed to send message");
|
||||
}
|
||||
|
||||
let registry = Rc::new(core.get_registry().expect("Failed to get registry"));
|
||||
|
||||
// Keep proxies and their listeners alive so that we can receive info events.
|
||||
|
||||
Reference in New Issue
Block a user