handle shutdown

This commit is contained in:
Erica Z 2024-11-02 21:20:26 +01:00
parent dcc528896a
commit f8d139e36f

View file

@ -133,7 +133,6 @@ impl Handle {
Error::from_return_code(unsafe { ffi::mpv_command(self.inner.as_ptr(), args) })
}
// TODO: return None on SHUTDOWN possibly?
pub fn tick(&self) -> Option<EventListener> {
// take listener before we drain the event queue, so we don't miss any notifications
let listener = self.wakeup.listen();
@ -157,6 +156,10 @@ impl Handle {
print!("[{prefix}] {level}: {text}");
}
ffi::mpv_event_id_MPV_EVENT_SHUTDOWN => {
return None; // good bye forever
}
11 => { /* deprecated, ignore */ }
_ => todo!("event {}", event.event_id),