mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 03:26:10 +08:00
pipewire connection: restart the outer loop
This commit is contained in:
committed by
Denis Drakhnia
parent
94323510aa
commit
7d6aae70c5
@@ -67,23 +67,14 @@ pub(super) fn thread_main(
|
|||||||
let core = match context.connect(None) {
|
let core = match context.connect(None) {
|
||||||
Ok(core) => Rc::new(core),
|
Ok(core) => Rc::new(core),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// If connection is failed, try to connect every 200ms
|
// If connection is failed, try to connect again in 200ms
|
||||||
let interval = Some(Duration::from_millis(200));
|
let interval = Some(Duration::from_millis(200));
|
||||||
|
|
||||||
let core = Rc::new(RefCell::new(None));
|
let timer = mainloop.add_timer(clone!(@strong mainloop => move |_| {
|
||||||
let timer = mainloop.add_timer(
|
|
||||||
clone!(@strong mainloop, @strong context, @strong core => move |_| {
|
|
||||||
if let Ok(x) = context.connect(None) {
|
|
||||||
core.replace(Some(x));
|
|
||||||
mainloop.quit();
|
mainloop.quit();
|
||||||
}
|
}));
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
timer
|
timer.update_timer(interval, None).into_result().unwrap();
|
||||||
.update_timer(interval, interval)
|
|
||||||
.into_result()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let receiver = pw_receiver.attach(&mainloop, {
|
let receiver = pw_receiver.attach(&mainloop, {
|
||||||
clone!(@strong mainloop, @strong is_stopped => move |msg|
|
clone!(@strong mainloop, @strong is_stopped => move |msg|
|
||||||
@@ -98,11 +89,7 @@ pub(super) fn thread_main(
|
|||||||
mainloop.run();
|
mainloop.run();
|
||||||
pw_receiver = receiver.deattach();
|
pw_receiver = receiver.deattach();
|
||||||
|
|
||||||
if is_stopped.get() {
|
continue;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rc::new(core.take().unwrap())
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user