If there is no alive process, don't try to send commands but store then into the queue

This commit is contained in:
Renaud Casenave-Péré 2011-08-27 22:07:59 +09:00
parent cd4eabe65f
commit 18d96b8a8f

13
empc.el
View file

@ -104,12 +104,13 @@ playlist is a vector of song ids, keeping the order of the songs
(defun empc-queue-push (object command closure fn)
"Enqueue '(COMMAND . (CLOSURE . FN)) to the queue of OBJECT.
Leave the idle state beforehand if necessary."
(if (empc-queue object)
(when (string= (empc-queue-head-command object) "idle\n")
(setcar (caaar object) "noidle\n")
(process-send-string (empc-process object) "noidle\n"))
(when command
(process-send-string (empc-process object) command)))
(when (empc-process object)
(if (empc-queue object)
(when (string= (empc-queue-head-command object) "idle\n")
(setcar (caaar object) "noidle\n")
(process-send-string (empc-process object) "noidle\n"))
(when command
(process-send-string (empc-process object) command))))
(setcar (car object)
(nconc (empc-queue object)
(list (cons command (cons closure fn))))))