mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
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:
parent
721de958ce
commit
e06e0fb33e
2 changed files with 11 additions and 14 deletions
|
@ -27,15 +27,6 @@ impl ActionRef {
|
||||||
gst::StructureRef::from_glib_borrow_mut((*action).structure)
|
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 {
|
impl Action {
|
||||||
|
@ -65,9 +56,9 @@ impl Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_validate_execute_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 {
|
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 action_type = ffi::gst_validate_get_action_type((*action).type_);
|
||||||
|
|
||||||
let res = ffi::gst_validate_execute_action(action_type, action);
|
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 {
|
impl std::fmt::Debug for Action {
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn test_action_types() {
|
||||||
|
|
||||||
// Write scenario to temporary file
|
// Write scenario to temporary file
|
||||||
let mut file = tempfile::NamedTempFile::new().unwrap();
|
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 runner = gst_validate::Runner::new();
|
||||||
let pipeline = gst::Pipeline::new();
|
let pipeline = gst::Pipeline::new();
|
||||||
|
@ -89,6 +89,7 @@ fn test_action_types() {
|
||||||
assert!(!*fails_called.lock().unwrap());
|
assert!(!*fails_called.lock().unwrap());
|
||||||
action.execute().expect_err("Action should have failed");
|
action.execute().expect_err("Action should have failed");
|
||||||
assert!(*fails_called.lock().unwrap());
|
assert!(*fails_called.lock().unwrap());
|
||||||
|
action.set_done();
|
||||||
|
|
||||||
gst_validate::ActionParameterBuilder::new("async", "Verify unused param are properly cleaned")
|
gst_validate::ActionParameterBuilder::new("async", "Verify unused param are properly cleaned")
|
||||||
.default_value("true")
|
.default_value("true")
|
||||||
|
@ -105,8 +106,6 @@ fn test_action_types() {
|
||||||
std::thread::spawn(glib::clone!(
|
std::thread::spawn(glib::clone!(
|
||||||
#[strong]
|
#[strong]
|
||||||
async_called,
|
async_called,
|
||||||
#[strong]
|
|
||||||
action,
|
|
||||||
move || {
|
move || {
|
||||||
*async_called.0.lock().unwrap() = true;
|
*async_called.0.lock().unwrap() = true;
|
||||||
action.set_done();
|
action.set_done();
|
||||||
|
|
Loading…
Reference in a new issue