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 aa5b8c7..9f54d61 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 */
   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);
       finished(ev);
+    }
     break;
   case SM_PLAYING:
     /* track ID is playing, DATA seconds played */
     break;
   case SM_PLAYING:
     /* track ID is playing, DATA seconds played */