X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/59cf25c47fbda22f3f4e14399f0436cc6ed2c56f..918393ff0ad35af6bb8b8c303f09da13a6c7587e:/server/play.c diff --git a/server/play.c b/server/play.c index 2889e42..c60d932 100644 --- a/server/play.c +++ b/server/play.c @@ -15,6 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +/** @file server/play.c + * @brief Playing tracks + */ #include "disorder-server.h" #include @@ -362,7 +365,8 @@ static int start(ev_source *ev, || write(sfd, q->id, l) < 0) fatal(errno, "writing to %s", addr.sun_path); /* Await the ack */ - read(sfd, &l, 1); + if (read(sfd, &l, 1) < 0) + fatal(errno, "reading ack from %s", addr.sun_path); /* Plumbing */ xdup2(np[0], 0); xdup2(sfd, 1); @@ -488,8 +492,7 @@ static void chosen_random_track(ev_source *ev, if(!track) return; /* Add the track to the queue */ - q = queue_add(track, 0, WHERE_END); - q->state = playing_random; + q = queue_add(track, 0, WHERE_END, origin_random); D(("picked %p (%s) at random", (void *)q, q->track)); queue_write(); /* Maybe a track can now be played */ @@ -531,9 +534,10 @@ void play(ev_source *ev) { } /* There must be at least one track in the queue. */ q = qhead.next; - /* If random play is disabled but the track is a random one then don't play - * it. play() will be called again when random play is re-enabled. */ - if(!random_enabled && q->state == playing_random) + /* If random play is disabled but the track is a non-adopted random one + * then don't play it. play() will be called again when random play is + * re-enabled. */ + if(!random_enabled && q->origin == origin_random) return; D(("taken %p (%s) from queue", (void *)q, q->track)); /* Try to start playing. */ @@ -639,8 +643,7 @@ void scratch(const char *who, const char *id) { * bother if playing is disabled) */ if(playing_is_enabled() && config->scratch.n) { int r = rand() * (double)config->scratch.n / (RAND_MAX + 1.0); - q = queue_add(config->scratch.s[r], who, WHERE_START); - q->state = playing_isscratch; + q = queue_add(config->scratch.s[r], who, WHERE_START, origin_scratch); } notify_scratch(playing->track, playing->submitter, who, time(0) - playing->played);