From 375d03194358c92f47e1303e3ee0efd0186178b4 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 31 Aug 2021 15:06:46 +0800 Subject: bongo: handle errors in timer * bongo.el (durand-bongo-mpv-player-tick): Now if the timer encounters an error, it will stop itself. Hopefully this can prevent Emacs from running the tick timer indefinitely that sometimes happens for no reason. --- bongo.el | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/bongo.el b/bongo.el index c78e723..8234c07 100644 --- a/bongo.el +++ b/bongo.el @@ -644,19 +644,22 @@ Modified by Durand." Also fetch the time-pos initially. Afterwards just stop the annoying timer." - (bongo--run-mpv-command player "time-pos" "get_property" "time-pos") - (let ((timer (bongo-player-get player 'timer))) - (cond - ;; ((or (not (bongo-player-running-p player)) - ;; (and (bongo-player-get player 'socket) - ;; (not (equal (process-status (bongo-player-get player 'socket)) - ;; 'open)))) - ;; (bongo-mpv-player-stop-timer player)) - ((null (bongo-player-total-time player)) - (bongo--run-mpv-command player "duration" "get_property" "duration")) - ;; ((null (bongo-player-get player 'metadata-fetched)) - ;; (bongo--run-mpv-command player "metadata" "get_property" "metadata")) - (t (bongo-mpv-player-stop-timer player))))) + (condition-case nil + (progn + (bongo--run-mpv-command player "time-pos" "get_property" "time-pos") + (let ((timer (bongo-player-get player 'timer))) + (cond + ;; ((or (not (bongo-player-running-p player)) + ;; (and (bongo-player-get player 'socket) + ;; (not (equal (process-status (bongo-player-get player 'socket)) + ;; 'open)))) + ;; (bongo-mpv-player-stop-timer player)) + ((null (bongo-player-total-time player)) + (bongo--run-mpv-command player "duration" "get_property" "duration")) + ;; ((null (bongo-player-get player 'metadata-fetched)) + ;; (bongo--run-mpv-command player "metadata" "get_property" "metadata")) + (t (bongo-mpv-player-stop-timer player))))) + (error (bongo-mpv-player-stop-timer player)))) ;;;###autoload (advice-add #'bongo-mpv-player-tick :override #'durand-bongo-mpv-player-tick) -- cgit v1.2.3-18-g5258