Compare commits

..

No commits in common. "3963c8404c5b20a7f04593e42cf151bcbda99fcf" and "20aaacd40e70b06327a6f36e2403a98d9d51b5dd" have entirely different histories.

2 changed files with 44 additions and 22 deletions

View file

@ -129,43 +129,64 @@ impl Handle {
Error::from_return_code(unsafe { ffi::mpv_command(self.inner.as_ptr(), args) })
}
// SAFETY: just in case format taking invalid values is Bad
unsafe fn observe_property_impl(
&self,
reply_userdata: u64,
name: &str,
format: ffi::mpv_format,
) -> Result<(), Error> {
pub fn observe_property(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
let name = CString::new(name).expect("null bytes in property name");
Error::from_return_code(unsafe {
ffi::mpv_observe_property(self.inner.as_ptr(), reply_userdata, name.as_ptr(), format)
ffi::mpv_observe_property(
self.inner.as_ptr(),
reply_userdata,
name.as_ptr(),
ffi::mpv_format_MPV_FORMAT_NONE,
)
})
}
pub fn observe_property(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
unsafe { self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_NONE) }
}
pub fn observe_property_int64(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
unsafe {
self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_INT64)
}
let name = CString::new(name).expect("null bytes in property name");
Error::from_return_code(unsafe {
ffi::mpv_observe_property(
self.inner.as_ptr(),
reply_userdata,
name.as_ptr(),
ffi::mpv_format_MPV_FORMAT_INT64,
)
})
}
pub fn observe_property_double(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
unsafe {
self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_DOUBLE)
}
let name = CString::new(name).expect("null bytes in property name");
Error::from_return_code(unsafe {
ffi::mpv_observe_property(
self.inner.as_ptr(),
reply_userdata,
name.as_ptr(),
ffi::mpv_format_MPV_FORMAT_DOUBLE,
)
})
}
pub fn observe_property_string(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
unsafe {
self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_STRING)
}
let name = CString::new(name).expect("null bytes in property name");
Error::from_return_code(unsafe {
ffi::mpv_observe_property(
self.inner.as_ptr(),
reply_userdata,
name.as_ptr(),
ffi::mpv_format_MPV_FORMAT_STRING,
)
})
}
pub fn observe_property_flag(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
unsafe { self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_FLAG) }
let name = CString::new(name).expect("null bytes in property name");
Error::from_return_code(unsafe {
ffi::mpv_observe_property(
self.inner.as_ptr(),
reply_userdata,
name.as_ptr(),
ffi::mpv_format_MPV_FORMAT_FLAG,
)
})
}
pub fn unobserve_property(&self, registered_reply_userdata: u64) -> Result<u32, Error> {

View file

@ -71,6 +71,7 @@ mod imp {
}
fn set_property(&self, id: usize, value: &glib::Value, _pspec: &glib::ParamSpec) {
dbg!(id, value);
match id {
1 => {
self.title.replace(value.get_owned().unwrap());