mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 13:31:00 +00:00
gtk4: Flush frames from the paintable when shutting down the sink
Otherwise it will continue showing the last frames forever and keep around the frames forever instead of rendering black. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/281 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1024>
This commit is contained in:
parent
71c268da14
commit
0c8e69ed7c
3 changed files with 20 additions and 0 deletions
|
@ -221,6 +221,14 @@ impl ElementImpl for PaintableSink {
|
|||
gst::StateChange::PausedToReady => {
|
||||
let _ = self.info.lock().unwrap().take();
|
||||
let _ = self.pending_frame.lock().unwrap().take();
|
||||
|
||||
let self_ = self.to_owned();
|
||||
utils::invoke_on_main_thread(move || {
|
||||
let paintable = self_.paintable.lock().unwrap();
|
||||
if let Some(paintable) = &*paintable {
|
||||
paintable.get().handle_flush_frames();
|
||||
}
|
||||
});
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -196,4 +196,12 @@ impl Paintable {
|
|||
self.obj().invalidate_contents();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn handle_flush_frames(&self) {
|
||||
gst::debug!(CAT, imp: self, "Flushing frames");
|
||||
self.paintables.borrow_mut().clear();
|
||||
self.cached_textures.borrow_mut().clear();
|
||||
self.obj().invalidate_size();
|
||||
self.obj().invalidate_contents();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,4 +33,8 @@ impl Paintable {
|
|||
pub(crate) fn handle_frame_changed(&self, frame: Option<Frame>) {
|
||||
self.imp().handle_frame_changed(frame);
|
||||
}
|
||||
|
||||
pub(crate) fn handle_flush_frames(&self) {
|
||||
self.imp().handle_flush_frames();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue