From f8d139e36f6c3de4d2af35dd98fa28e2aacbc2ad Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 2 Nov 2024 21:20:26 +0100 Subject: [PATCH] handle shutdown --- src/mpv.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mpv.rs b/src/mpv.rs index 6e1332d..24a5adc 100644 --- a/src/mpv.rs +++ b/src/mpv.rs @@ -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 { // 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),