dedup
This commit is contained in:
parent
20aaacd40e
commit
ad30fed23d
1 changed files with 22 additions and 43 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> {
|
||||
|
|
Loading…
Reference in a new issue