Compare commits
2 commits
20aaacd40e
...
3963c8404c
Author | SHA1 | Date | |
---|---|---|---|
3963c8404c | |||
ad30fed23d |
2 changed files with 22 additions and 44 deletions
|
@ -129,64 +129,43 @@ impl Handle {
|
|||
Error::from_return_code(unsafe { ffi::mpv_command(self.inner.as_ptr(), args) })
|
||||
}
|
||||
|
||||
pub fn observe_property(&self, reply_userdata: u64, name: &str) -> Result<(), Error> {
|
||||
// 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> {
|
||||
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_NONE,
|
||||
)
|
||||
ffi::mpv_observe_property(self.inner.as_ptr(), reply_userdata, name.as_ptr(), format)
|
||||
})
|
||||
}
|
||||
|
||||
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> {
|
||||
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,
|
||||
)
|
||||
})
|
||||
unsafe {
|
||||
self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_INT64)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn observe_property_double(&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(),
|
||||
ffi::mpv_format_MPV_FORMAT_DOUBLE,
|
||||
)
|
||||
})
|
||||
unsafe {
|
||||
self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_DOUBLE)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn observe_property_string(&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(),
|
||||
ffi::mpv_format_MPV_FORMAT_STRING,
|
||||
)
|
||||
})
|
||||
unsafe {
|
||||
self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_STRING)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn observe_property_flag(&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(),
|
||||
ffi::mpv_format_MPV_FORMAT_FLAG,
|
||||
)
|
||||
})
|
||||
unsafe { self.observe_property_impl(reply_userdata, name, ffi::mpv_format_MPV_FORMAT_FLAG) }
|
||||
}
|
||||
|
||||
pub fn unobserve_property(&self, registered_reply_userdata: u64) -> Result<u32, Error> {
|
||||
|
|
|
@ -71,7 +71,6 @@ 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());
|
||||
|
|
Loading…
Reference in a new issue