* initialization. */
#define SM_READY 132
+/** @brief Cancelled track @c id which wasn't playing */
+#define SM_STILLBORN 133
+
void speaker_send(int fd, const struct speaker_message *sm);
/* Send a message. */
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);
- break;
- case SM_UNKNOWN:
- /* we asked for an unknown track to be cancelled */
+ 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;
report();
break;
case SM_CANCEL:
- D(("SM_CANCEL %s", sm.id));
+ D(("SM_CANCEL %s", sm.id));
t = removetrack(sm.id);
if(t) {
if(t == playing) {
+ /* scratching the playing track */
sm.type = SM_FINISHED;
- strcpy(sm.id, playing->id);
- speaker_send(1, &sm);
playing = 0;
+ } else {
+ /* Could be scratching the playing track before it's quite got
+ * going, or could be just removing a track from the queue. We
+ * log more because there's been a bug here recently than because
+ * it's particularly interesting; the log message will be removed
+ * if no further problems show up. */
+ info("SM_CANCEL for nonplaying track %s", sm.id);
+ sm.type = SM_STILLBORN;
}
+ strcpy(sm.id, t->id);
destroy(t);
} else {
+ /* Probably scratching the playing track well before it's got
+ * going, but could indicate a bug, so we log this as an error. */
sm.type = SM_UNKNOWN;
- speaker_send(1, &sm);
error(0, "SM_CANCEL for unknown track %s", sm.id);
}
+ speaker_send(1, &sm);
report();
break;
case SM_RELOAD: