commit 8d08767078347495fc28f6a97ad1e5e1b3b6f5f2 from: Omar Polo date: Sat Jul 09 10:48:56 2022 UTC reimplement `restart' on top of seek commit - 3aa75c64d7d3cdcf3988263eaf4d073dc7c89e50 commit + 8d08767078347495fc28f6a97ad1e5e1b3b6f5f2 blob - bf368c371689924a2eaedfb47abd27af8a2f6db4 blob + 807d19af4e75d3e1cc13776b84f878af1b8330fe --- amused.c +++ amused.c @@ -497,19 +497,6 @@ main_playlist_previous(void) } void -main_restart_track(void) -{ - if (current_song == NULL) - return; - - if (main_play_song(current_song)) - return; - - playlist_dropcurrent(); - main_playlist_advance(); -} - -void main_senderr(struct imsgev *iev, const char *msg) { imsg_compose_event(iev, IMSG_CTL_ERR, 0, 0, -1, blob - 5bfef5817b5b06a34ca123c200879905a1161b6a blob + 0327648d1507905618118f4ceda5bef4638be8a0 --- amused.h +++ amused.h @@ -39,7 +39,6 @@ enum imsg_type { IMSG_CTL_TOGGLE_PLAY, IMSG_CTL_PAUSE, IMSG_CTL_STOP, - IMSG_CTL_RESTART, IMSG_CTL_FLUSH, IMSG_CTL_SHOW, IMSG_CTL_STATUS, @@ -72,7 +71,7 @@ enum actions { PAUSE, TOGGLE, STOP, - RESTART, + RESTART, /* seek to zero */ ADD, FLUSH, SHOW, @@ -138,7 +137,6 @@ void main_playlist_jump(struct imsgev *, struct imsg void main_playlist_resume(void); void main_playlist_advance(void); void main_playlist_previous(void); -void main_restart_track(void); void main_senderr(struct imsgev *, const char *); void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *); void main_send_playlist(struct imsgev *); blob - abf505eaf22728d250eee8a0e5d0aab25d7b86fa blob + 706e2a01ee1b31c5ba370a5405a5157877355faa --- control.c +++ control.c @@ -320,11 +320,6 @@ control_dispatch_imsg(int fd, short event, void *bula) main_send_player(IMSG_STOP, -1, NULL, 0); control_notify(&c->iev, imsg.hdr.type); break; - case IMSG_CTL_RESTART: - main_send_player(IMSG_STOP, -1, NULL, 0); - main_restart_track(); - control_notify(&c->iev, imsg.hdr.type); - break; case IMSG_CTL_FLUSH: playlist_truncate(); control_notify(&c->iev, imsg.hdr.type); blob - c4629edaa511ae2d9c584c4d1ac6c9458242e1ee blob + 9b3ad2a9c8311d24800ae4635ebacf817c1c49af --- ctl.c +++ ctl.c @@ -255,8 +255,6 @@ imsg_name(int type) return "pause"; case IMSG_CTL_STOP: return "stop"; - case IMSG_CTL_RESTART: - return "restart"; case IMSG_CTL_FLUSH: return "flush"; case IMSG_CTL_NEXT: @@ -329,14 +327,6 @@ ctlaction(struct parse_result *res) case STOP: imsg_compose(ibuf, IMSG_CTL_STOP, 0, 0, -1, NULL, 0); break; - case RESTART: - imsg_compose(ibuf, IMSG_CTL_RESTART, 0, 0, -1, NULL, 0); - if (verbose) { - imsg_compose(ibuf, IMSG_CTL_STATUS, 0, 0, -1, - NULL, 0); - done = 0; - } - break; case ADD: done = 0; for (i = 0; res->files[i] != NULL; ++i) { @@ -399,6 +389,9 @@ ctlaction(struct parse_result *res) imsg_compose(ibuf, IMSG_CTL_MONITOR, 0, 0, -1, NULL, 0); break; + case RESTART: + memset(&res->seek, 0, sizeof(res->seek)); + /* fallthrough */ case SEEK: imsg_compose(ibuf, IMSG_CTL_SEEK, 0, 0, -1, &res->seek, sizeof(res->seek)); @@ -708,8 +701,8 @@ ctl_monitor(struct parse_result *res, int argc, char * res->monitor[IMSG_CTL_PAUSE] = 1; else if (!strcmp(tok, "stop")) res->monitor[IMSG_CTL_STOP] = 1; - else if (!strcmp(tok, "restart")) - res->monitor[IMSG_CTL_RESTART] = 1; + else if (!strcmp(tok, "restart")) /* compat */ + res->monitor[IMSG_CTL_SEEK] = 1; else if (!strcmp(tok, "flush")) res->monitor[IMSG_CTL_FLUSH] = 1; else if (!strcmp(tok, "next"))