mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-12-18 14:06:30 +00:00
player: keep a reference to bus_watch_guard
In order to receive the message from the bus the API enforces to keep a reference to the bus_watch_guard otherwise the watch gets lost.
This commit is contained in:
parent
24121856ee
commit
9c03de5d00
1 changed files with 4 additions and 1 deletions
|
@ -67,6 +67,7 @@ pub struct PlayerInner {
|
||||||
pipeline: RefCell<Option<gst::Pipeline>>,
|
pipeline: RefCell<Option<gst::Pipeline>>,
|
||||||
current_state: Cell<PipelineState>,
|
current_state: Cell<PipelineState>,
|
||||||
n_video_sink: Cell<usize>,
|
n_video_sink: Cell<usize>,
|
||||||
|
bus_watch_guard: RefCell<Option<gst::bus::BusWatchGuard>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
|
@ -76,6 +77,7 @@ impl Player {
|
||||||
pipeline: RefCell::new(None),
|
pipeline: RefCell::new(None),
|
||||||
current_state: Cell::new(PipelineState::Stopped),
|
current_state: Cell::new(PipelineState::Stopped),
|
||||||
n_video_sink: Cell::new(0),
|
n_video_sink: Cell::new(0),
|
||||||
|
bus_watch_guard: RefCell::new(None),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Ok(pipeline)
|
Ok(pipeline)
|
||||||
|
@ -176,12 +178,13 @@ impl Player {
|
||||||
|
|
||||||
let bus = pipeline.bus().expect("Pipeline had no bus");
|
let bus = pipeline.bus().expect("Pipeline had no bus");
|
||||||
let pipeline_weak = self.downgrade();
|
let pipeline_weak = self.downgrade();
|
||||||
let _ = bus.add_watch_local(move |_bus, msg| {
|
let bus_watch_guard = bus.add_watch_local(move |_bus, msg| {
|
||||||
let pipeline = upgrade_weak!(pipeline_weak, glib::ControlFlow::Break);
|
let pipeline = upgrade_weak!(pipeline_weak, glib::ControlFlow::Break);
|
||||||
pipeline.on_pipeline_message(msg);
|
pipeline.on_pipeline_message(msg);
|
||||||
glib::ControlFlow::Continue
|
glib::ControlFlow::Continue
|
||||||
})?;
|
})?;
|
||||||
*self.pipeline.borrow_mut() = Some(pipeline);
|
*self.pipeline.borrow_mut() = Some(pipeline);
|
||||||
|
*self.bus_watch_guard.borrow_mut() = Some(bus_watch_guard);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set_state(new_state).map_err(|error| {
|
self.set_state(new_state).map_err(|error| {
|
||||||
|
|
Loading…
Reference in a new issue