chiark / gitweb /
Fix a race between track startup and scratching. Basically if the
[disorder] / server / play.c
index 7f863ce369aae7358712f40c29503757ce2340a4..c447aa798d18487970b6fcd9edb53ce2f7aab5b8 100644 (file)
@@ -111,10 +111,11 @@ static int speaker_readable(ev_source *ev, int fd,
     D(("SM_PAUSED %s %ld", sm.id, sm.data));
     playing->sofar = sm.data;
     break;
-  case SM_FINISHED:
-    /* the playing track finished */
-    D(("SM_FINISHED %s", sm.id));
-    finished(ev);
+  case SM_FINISHED:                    /* scratched the playing track */
+  case SM_STILLBORN:                   /* scratched too early */
+  case SM_UNKNOWN:                     /* scratched WAY too early */
+    if(playing && !strcmp(sm.id, playing->id))
+      finished(ev);
     break;
   case SM_PLAYING:
     /* track ID is playing, DATA seconds played */
@@ -427,6 +428,7 @@ static int start(ev_source *ev,
           * (but it should be for play_track() */
          execlp("disorder-normalize", "disorder-normalize",
                 log_default == &log_syslog ? "--syslog" : "--no-syslog",
+                "--config", configfile,
                 (char *)0);
          fatal(errno, "executing disorder-normalize");
          /* end of the innermost fork */