summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-08-31 15:06:46 +0800
committerJSDurand <mmemmew@gmail.com>2021-08-31 15:06:46 +0800
commit375d03194358c92f47e1303e3ee0efd0186178b4 (patch)
tree17843cb624e9be63d562b0d33948c10c08f729f4
parente07d8459dec19fabb315a7da13c9cba7dcadb7fc (diff)
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.
-rw-r--r--bongo.el29
1 files 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)