chiark / gitweb /
Merge from disorder.dev.
[disorder] / server / speaker.c
index b41c94f844d8f9cee721c6d959c174ddc09ddda5..892e33c960ceb631578d217d202724af22254dc2 100644 (file)
@@ -370,7 +370,7 @@ static void report(void) {
     strcpy(sm.id, playing->id);
     sm.data = playing->played / (uaudio_rate * uaudio_channels);
     speaker_send(1, &sm);
     strcpy(sm.id, playing->id);
     sm.data = playing->played / (uaudio_rate * uaudio_channels);
     speaker_send(1, &sm);
-    time(&last_report);
+    xtime(&last_report);
   }
 }
 
   }
 }
 
@@ -426,8 +426,10 @@ static size_t speaker_callback(void *buffer,
       if(playing->start == sizeof playing->buffer)
         playing->start = 0;
       /* See if we've reached the end of the track */
       if(playing->start == sizeof playing->buffer)
         playing->start = 0;
       /* See if we've reached the end of the track */
-      if(playing->used == 0 && playing->eof)
-        write(sigpipe[1], "", 1);
+      if(playing->used == 0 && playing->eof) {
+        int ignored = write(sigpipe[1], "", 1);
+        (void) ignored;
+      }
       provided_samples = bytes / uaudio_sample_size;
       playing->played += provided_samples;
     }
       provided_samples = bytes / uaudio_sample_size;
       playing->played += provided_samples;
     }
@@ -558,6 +560,14 @@ static void mainloop(void) {
           D(("SM_PLAY %s fd %d", t->id, t->fd));
           if(t->fd == -1)
             error(0, "cannot play track because no connection arrived");
           D(("SM_PLAY %s fd %d", t->id, t->fd));
           if(t->fd == -1)
             error(0, "cannot play track because no connection arrived");
+          /* TODO as things stand we often report this error message but then
+           * appear to proceed successfully.  Understanding why requires a look
+           * at play.c: we call prepare() which makes the connection in a child
+           * process, and then sends the SM_PLAY in the parent process.  The
+           * latter may well be faster.  As it happens this is harmless; we'll
+           * just sit around sending silence until the decoder connects and
+           * starts sending some sample data.  But is is annoying and ought to
+           * be fixed. */
           pending_playing = t;
           /* If nothing is currently playing then we'll switch to the pending
            * track below so there's no point distinguishing the situations
           pending_playing = t;
           /* If nothing is currently playing then we'll switch to the pending
            * track below so there's no point distinguishing the situations
@@ -608,7 +618,7 @@ static void mainloop(void) {
          break;
        case SM_RELOAD:
           D(("SM_RELOAD"));
          break;
        case SM_RELOAD:
           D(("SM_RELOAD"));
-         if(config_read(1))
+         if(config_read(1, NULL))
             error(0, "cannot read configuration");
           info("reloaded configuration");
          break;
             error(0, "cannot read configuration");
           info("reloaded configuration");
          break;
@@ -626,8 +636,9 @@ static void mainloop(void) {
      * interrupted poll(). */
     if(fds[sigpipe_slot].revents & POLLIN) {
       char buffer[64];
      * interrupted poll(). */
     if(fds[sigpipe_slot].revents & POLLIN) {
       char buffer[64];
+      int ignored; (void)ignored;
 
 
-      read(sigpipe[0], buffer, sizeof buffer);
+      ignored = read(sigpipe[0], buffer, sizeof buffer);
     }
     /* Send SM_FINISHED when we're near the end of the track.
      *
     }
     /* Send SM_FINISHED when we're near the end of the track.
      *
@@ -673,7 +684,7 @@ static void mainloop(void) {
       }
     }
     /* If we've not reported our state for a second do so now. */
       }
     }
     /* If we've not reported our state for a second do so now. */
-    if(force_report || time(0) > last_report)
+    if(force_report || xtime(0) > last_report)
       report();
   }
 }
       report();
   }
 }
@@ -707,7 +718,7 @@ int main(int argc, char **argv) {
     log_default = &log_syslog;
   }
   config_uaudio_apis = uaudio_apis;
     log_default = &log_syslog;
   }
   config_uaudio_apis = uaudio_apis;
-  if(config_read(1)) fatal(0, "cannot read configuration");
+  if(config_read(1, NULL)) fatal(0, "cannot read configuration");
   /* ignore SIGPIPE */
   signal(SIGPIPE, SIG_IGN);
   /* set nice value */
   /* ignore SIGPIPE */
   signal(SIGPIPE, SIG_IGN);
   /* set nice value */