chiark / gitweb /
doxygen fixes
[disorder] / server / play.c
index 35d756bc0d0880ebd96b613d2c6fa83612136b8e..04d7d0117d54f2508560fa3ba1fa0b19e2940827 100644 (file)
@@ -43,6 +43,7 @@
 #include "mem.h"
 #include "configuration.h"
 #include "queue.h"
+#include "server-queue.h"
 #include "trackdb.h"
 #include "play.h"
 #include "plugin.h"
@@ -164,7 +165,7 @@ void speaker_setup(ev_source *ev) {
   /* Wait for the speaker to be ready */
   speaker_recv(speaker_fd, &sm);
   nonblock(speaker_fd);
-  ev_fd(ev, ev_read, speaker_fd, speaker_readable, 0);
+  ev_fd(ev, ev_read, speaker_fd, speaker_readable, 0, "speaker read");
 }
 
 void speaker_reload(void) {
@@ -284,15 +285,15 @@ static int find_player(const struct queue_entry *q) {
 }
 
 /* Return values from start() */
-#define START_OK 0                     /* Succeeded. */
-#define START_HARDFAIL 1               /* Track is broken. */
-#define START_SOFTFAIL 2          /* Track OK, system (temporarily?) broken */
+#define START_OK 0                     /**< @brief Succeeded. */
+#define START_HARDFAIL 1               /**< @brief Track is broken. */
+#define START_SOFTFAIL 2          /**< @brief Track OK, system (temporarily?) broken */
 
 /** @brief Play or prepare @p q
  * @param ev Event loop
  * @param q Track to play/prepare
  * @param prepare_only If true, only prepares track
- * @return @ref START_OK, @ref START_HARDFAIL or @ref START_SOFTFTAIL
+ * @return @ref START_OK, @ref START_HARDFAIL or @ref START_SOFTFAIL
  */
 static int start(ev_source *ev,
                 struct queue_entry *q,
@@ -343,8 +344,11 @@ static int start(ev_source *ev,
     }
   /* Use the second arg as the tag if available (it's probably a command name),
    * otherwise the module name. */
-  lfd = logfd(ev, (config->player.s[n].s[2]
-                  ? config->player.s[n].s[2] : config->player.s[n].s[1]));
+  if(!isatty(2))
+    lfd = logfd(ev, (config->player.s[n].s[2]
+                    ? config->player.s[n].s[2] : config->player.s[n].s[1]));
+  else
+    lfd = -1;
   optc = config->player.s[n].n - 2;
   optv = (void *)&config->player.s[n].s[2];
   while(optc > 0 && optv[0][0] == '-') {
@@ -371,9 +375,11 @@ static int start(ev_source *ev,
     exitfn = _exit;
     ev_signal_atfork(ev);
     signal(SIGPIPE, SIG_DFL);
-    xdup2(lfd, 1);
-    xdup2(lfd, 2);
-    xclose(lfd);                       /* tidy up */
+    if(lfd != -1) {
+      xdup2(lfd, 1);
+      xdup2(lfd, 2);
+      xclose(lfd);                     /* tidy up */
+    }
     setpgid(0, 0);
     if((q->type & DISORDER_PLAYER_TYPEMASK) == DISORDER_PLAYER_RAW) {
       /* "Raw" format players always have their output send down a pipe
@@ -467,11 +473,13 @@ static int start(ev_source *ev,
     error(errno, "error calling fork");
     if(q->type & DISORDER_PLAYER_PREFORK)
       play_cleanup(q->pl, q->data);    /* else would leak */
-    xclose(lfd);
+    if(lfd != -1)
+      xclose(lfd);
     return START_SOFTFAIL;
   }
   store_player_pid(q->id, pid);
-  xclose(lfd);
+  if(lfd != -1)
+    xclose(lfd);
   setpgid(pid, pid);
   ev_child(ev, pid, 0, player_finished, q);
   D(("player subprocess ID %lu", (unsigned long)pid));