enable mpv verbose logging
This commit is contained in:
parent
b966bc18df
commit
8ab1e1e1fa
1 changed files with 15 additions and 2 deletions
17
src/mpv.rs
17
src/mpv.rs
|
@ -86,6 +86,9 @@ impl Handle {
|
|||
);
|
||||
}
|
||||
|
||||
// set up verbose logging for now
|
||||
Error::from_return_code(unsafe { ffi::mpv_request_log_messages(inner.as_ptr(), c"v".as_ptr()) }).unwrap();
|
||||
|
||||
// TODO: maybe we need to set something before initialization, but idk
|
||||
// also wed need a builder, since "Note that you should avoid doing concurrent accesses on the uninitialized client handle."
|
||||
Error::from_return_code(unsafe { ffi::mpv_initialize(inner.as_ptr()) })
|
||||
|
@ -116,6 +119,15 @@ impl Handle {
|
|||
match event.event_id {
|
||||
ffi::mpv_event_id_MPV_EVENT_NONE => break,
|
||||
|
||||
ffi::mpv_event_id_MPV_EVENT_LOG_MESSAGE => {
|
||||
let data = unsafe { &*(event.data as *mut ffi::mpv_event_log_message) };
|
||||
// TODO: actual logging?
|
||||
let prefix = unsafe { CStr::from_ptr(data.prefix) }.to_str().unwrap();
|
||||
let level = unsafe { CStr::from_ptr(data.level) }.to_str().unwrap();
|
||||
let text = unsafe { CStr::from_ptr(data.text) }.to_str().unwrap();
|
||||
print!("[{prefix}] {level}: {text}");
|
||||
},
|
||||
|
||||
11 => { /* deprecated, ignore */ }
|
||||
|
||||
_ => todo!("event {}", event.event_id),
|
||||
|
@ -134,8 +146,9 @@ impl Handle {
|
|||
|
||||
impl Drop for Handle {
|
||||
fn drop(&mut self) {
|
||||
// destroy? terminate_destroy??
|
||||
todo!()
|
||||
unsafe {
|
||||
ffi::mpv_destroy(self.inner.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue