chiark / gitweb /
Ensure we still send a 'completed' event in various dubious edge
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 13 Dec 2009 15:53:42 +0000 (15:53 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 13 Dec 2009 15:53:42 +0000 (15:53 +0000)
cases, especially common in scratching.

server/play.c

index aa5b8c7270eaa4e52c4114efc5e48a89ab7d22e7..9f54d615bf77d547fd240b2412d14f971f360855 100644 (file)
@@ -83,8 +83,13 @@ static int speaker_readable(ev_source *ev, int fd,
   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))
+    if(playing && !strcmp(sm.id, playing->id)) {
+      if((playing->state == playing_unplayed
+          || playing->state == playing_started)
+         && sm.type == SM_FINISHED)
+        playing->state = playing_ok;
       finished(ev);
+    }
     break;
   case SM_PLAYING:
     /* track ID is playing, DATA seconds played */