branch: elpa/mpv commit d7bb3a70829203be827505c40f761d197494817b Author: Johann Klähn <joh...@jklaehn.de> Commit: Johann Klähn <joh...@jklaehn.de>
Add sleep and timeout to mpv-kill and mpv-play Fixes #4 --- mpv.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mpv.el b/mpv.el index b057443711..54d696c34d 100644 --- a/mpv.el +++ b/mpv.el @@ -116,8 +116,11 @@ prepended to ARGS." (when (file-exists-p socket) (with-demoted-errors (delete-file socket))) (run-hooks 'mpv-on-exit-hook)))) - (while (and (mpv-live-p) (not (file-exists-p socket))) - (sleep-for 0.05)) + (with-timeout + (0.5 (mpv-kill) + (error "Failed to connect to mpv")) + (while (not (file-exists-p socket)) + (sleep-for 0.05))) (setq mpv--queue (tq-create (make-network-process :name "mpv-socket" :family 'local @@ -230,6 +233,10 @@ See `mpv-start' if you need to pass further arguments and (tq-close mpv--queue)) (when (mpv-live-p) (kill-process mpv--process)) + (with-timeout + (0.5 (error "Failed to kill mpv")) + (while (mpv-live-p) + (sleep-for 0.05))) (setq mpv--process nil) (setq mpv--queue nil))