validate: Fix refcount handling for action.set_done()

Also fix the test making proper use of it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1586>
This commit is contained in:
Thibault Saunier 2024-10-30 20:59:39 -03:00 committed by GStreamer Marge Bot
parent 721de958ce
commit e06e0fb33e
2 changed files with 11 additions and 14 deletions

View file

@ -27,15 +27,6 @@ impl ActionRef {
gst::StructureRef::from_glib_borrow_mut((*action).structure)
}
}
#[doc(alias = "gst_validate_action_set_done")]
pub fn set_done(&self) {
unsafe {
let action = self.as_mut_ptr();
ffi::gst_validate_action_set_done(action);
}
}
}
impl Action {
@ -65,9 +56,9 @@ impl Action {
}
#[doc(alias = "gst_validate_execute_action")]
pub fn execute(&self) -> Result<crate::ActionSuccess, crate::ActionError> {
pub fn execute(self) -> Result<crate::ActionSuccess, crate::ActionError> {
unsafe {
let action: *mut ffi::GstValidateAction = self.to_glib_none().0;
let action: *mut ffi::GstValidateAction = self.to_glib_full();
let action_type = ffi::gst_validate_get_action_type((*action).type_);
let res = ffi::gst_validate_execute_action(action_type, action);
@ -79,6 +70,13 @@ impl Action {
}
}
}
#[doc(alias = "gst_validate_action_set_done")]
pub fn set_done(self) {
unsafe {
ffi::gst_validate_action_set_done(self.into_glib_ptr());
}
}
}
impl std::fmt::Debug for Action {

View file

@ -60,7 +60,7 @@ fn test_action_types() {
// Write scenario to temporary file
let mut file = tempfile::NamedTempFile::new().unwrap();
file.write_all(b"succeeds").unwrap();
file.write_all(b"stop, on-message=eos").unwrap();
let runner = gst_validate::Runner::new();
let pipeline = gst::Pipeline::new();
@ -89,6 +89,7 @@ fn test_action_types() {
assert!(!*fails_called.lock().unwrap());
action.execute().expect_err("Action should have failed");
assert!(*fails_called.lock().unwrap());
action.set_done();
gst_validate::ActionParameterBuilder::new("async", "Verify unused param are properly cleaned")
.default_value("true")
@ -105,8 +106,6 @@ fn test_action_types() {
std::thread::spawn(glib::clone!(
#[strong]
async_called,
#[strong]
action,
move || {
*async_called.0.lock().unwrap() = true;
action.set_done();