chiark / gitweb /
Fix a race between track startup and scratching. Basically if the
[disorder] / server / play.c
index fa46329fc63a5436073ff018e86b5a336a09b3d7..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 */