commit - f3bd773be6486fa2c212ff27aee53e3894bcc51d
commit + 310ef57cd092b0af07f656a3b8d40eea6a07ddea
blob - a11b339bdc978e30d749022cfe6e17ca634bca8f
blob + ba393dd2b0aa1bbe05e5b2204c9d9360e90188b4
--- amused.h
+++ amused.h
IMSG_CTL_NEXT,
IMSG_CTL_PREV,
IMSG_CTL_JUMP,
+ IMSG_CTL_REPEAT, /* struct player_repeat */
IMSG_CTL_BEGIN,
IMSG_CTL_ADD, /* path to a file */
NEXT,
LOAD,
JUMP,
+ REPEAT,
};
struct ctl_command;
+struct player_repeat {
+ int repeat_one;
+ int repeat_all;
+};
+
struct parse_result {
enum actions action;
char **files;
const char *file;
int pretty;
+ struct player_repeat rep;
struct ctl_command *ctl;
};
blob - e00746ebf384ba0bc7a061e3cad4c88fbc8c60b9
blob + 8a1263255b91f3fda656a08f0eb16ff40921810d
--- control.c
+++ control.c
void
control_dispatch_imsg(int fd, short event, void *bula)
{
- struct ctl_conn *c;
- struct imsg imsg;
- ssize_t n;
+ struct ctl_conn *c;
+ struct imsg imsg;
+ struct player_repeat rp;
+ ssize_t n;
if ((c = control_connbyfd(fd)) == NULL) {
log_warnx("%s: fd %d: not found", __func__, fd);
break;
case IMSG_CTL_JUMP:
main_playlist_jump(&c->iev, &imsg);
+ break;
+ case IMSG_CTL_REPEAT:
+ if (IMSG_DATA_SIZE(imsg) != sizeof(rp)) {
+ log_warnx("%s: got wrong size", __func__);
+ break;
+ }
+ memcpy(&rp, imsg.data, sizeof(rp));
+ if (rp.repeat_all != -1)
+ repeat_all = rp.repeat_all;
+ if (rp.repeat_one != -1)
+ repeat_one = rp.repeat_one;
break;
case IMSG_CTL_BEGIN:
if (control_state.tx != -1) {
blob - 63feafe6ba8676e50d2a725b225aebe35ab74f30
blob + 4a5f6e06c1b5f7d147203eb13605df28d3add24a
--- ctl.c
+++ ctl.c
int ctl_show(struct parse_result *, int, char **);
int ctl_load(struct parse_result *, int, char **);
int ctl_jump(struct parse_result *, int, char **);
+int ctl_repeat(struct parse_result *, int, char **);
struct ctl_command ctl_commands[] = {
{ "play", PLAY, ctl_noarg, "" },
{ "prev", PREV, ctl_noarg, "" },
{ "load", LOAD, ctl_load, "[file]", 1 },
{ "jump", JUMP, ctl_jump, "pattern" },
+ { "repeat", REPEAT, ctl_repeat, "one|all on|off" },
{ NULL },
};
done = 0;
ret = jump_req(res->file);
break;
+ case REPEAT:
+ imsg_compose(ibuf, IMSG_CTL_REPEAT, 0, 0, -1,
+ &res->rep, sizeof(res->rep));
+ break;
case NONE:
/* action not expected */
fatalx("invalid action %u", res->action);
ctl_usage(res->ctl);
res->file = argv[0];
+ return ctlaction(res);
+}
+
+int
+ctl_repeat(struct parse_result *res, int argc, char **argv)
+{
+ int ch, b;
+
+ while ((ch = getopt(argc, argv, "")) != -1)
+ ctl_usage(res->ctl);
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 2)
+ ctl_usage(res->ctl);
+
+ if (!strcmp(argv[1], "on"))
+ b = 1;
+ else if (!strcmp(argv[1], "off"))
+ b = 0;
+ else
+ ctl_usage(res->ctl);
+
+ res->rep.repeat_one = -1;
+ res->rep.repeat_all = -1;
+ if (!strcmp(argv[0], "one"))
+ res->rep.repeat_one = b;
+ else if (!strcmp(argv[0], "all"))
+ res->rep.repeat_all = b;
+ else
+ ctl_usage(res->ctl);
+
return ctlaction(res);
}