commit ddaffed69d4fe7f814777d57bc373b2a40d4abb7 from: Omar Polo date: Sun Jan 21 12:04:48 2024 UTC convert to imsg_get_type() commit - 5c9741443b589c7f51dc66ae1b0e0c8708e85f69 commit + ddaffed69d4fe7f814777d57bc373b2a40d4abb7 blob - b4c6b13bb50662e21b5c2c07350b4534676818f0 blob + 9d24e5b56fc0a49727e701d8d733c4e1b57d0ecb --- amused.c +++ amused.c @@ -127,7 +127,7 @@ main_dispatch_player(int sig, int event, void *d) if (n == 0) /* No more messages. */ break; - switch (imsg.hdr.type) { + switch (imsg_get_type(&imsg)) { case IMSG_POS: if (imsg_get_data(&imsg, ¤t_position, sizeof(current_position)) == -1) @@ -172,7 +172,7 @@ main_dispatch_player(int sig, int event, void *d) break; default: log_debug("%s: error handling imsg %d", __func__, - imsg.hdr.type); + imsg_get_type(&imsg)); break; } imsg_free(&imsg); blob - 9d5e547e17bd94286648f3a42a40c7e637c55821 blob + 257d02f7f78471a6a377b68930cc73a5e8554f20 --- control.c +++ control.c @@ -276,6 +276,7 @@ control_dispatch_imsg(int fd, int event, void *bula) struct player_mode mode; struct player_seek seek; ssize_t n, off; + int type; if ((c = control_connbyfd(fd)) == NULL) { log_warnx("%s: fd %d: not found", __func__, fd); @@ -306,7 +307,7 @@ control_dispatch_imsg(int fd, int event, void *bula) if (n == 0) break; - switch (imsg.hdr.type) { + switch (type = imsg_get_type(&imsg)) { case IMSG_CTL_PLAY: switch (play_state) { case STATE_STOPPED: @@ -320,7 +321,7 @@ control_dispatch_imsg(int fd, int event, void *bula) main_send_player(IMSG_RESUME, -1, NULL ,0); break; } - control_notify(imsg.hdr.type); + control_notify(type); break; case IMSG_CTL_TOGGLE_PLAY: switch (play_state) { @@ -345,14 +346,14 @@ control_dispatch_imsg(int fd, int event, void *bula) break; play_state = STATE_PAUSED; main_send_player(IMSG_PAUSE, -1, NULL, 0); - control_notify(imsg.hdr.type); + control_notify(type); break; case IMSG_CTL_STOP: if (play_state == STATE_STOPPED) break; play_state = STATE_STOPPED; main_send_player(IMSG_STOP, -1, NULL, 0); - control_notify(imsg.hdr.type); + control_notify(type); break; case IMSG_CTL_FLUSH: playlist_truncate(); @@ -365,12 +366,12 @@ control_dispatch_imsg(int fd, int event, void *bula) main_send_status(&c->iev); break; case IMSG_CTL_NEXT: - control_notify(imsg.hdr.type); + control_notify(type); main_send_player(IMSG_STOP, -1, NULL, 0); main_playlist_advance(); break; case IMSG_CTL_PREV: - control_notify(imsg.hdr.type); + control_notify(type); main_send_player(IMSG_STOP, -1, NULL, 0); main_playlist_previous(); break; @@ -385,7 +386,7 @@ control_dispatch_imsg(int fd, int event, void *bula) consume = new_mode(consume, mode.consume); repeat_all = new_mode(repeat_all, mode.repeat_all); repeat_one = new_mode(repeat_one, mode.repeat_one); - control_notify(imsg.hdr.type); + control_notify(type); break; case IMSG_CTL_BEGIN: if (control_state.tx != -1) { @@ -405,7 +406,7 @@ control_dispatch_imsg(int fd, int event, void *bula) main_enqueue(control_state.tx != -1, &control_state.play,&c->iev, &imsg); if (control_state.tx == -1) - control_notify(imsg.hdr.type); + control_notify(type); break; case IMSG_CTL_COMMIT: if (control_state.tx != imsgbuf->fd) { @@ -422,7 +423,7 @@ control_dispatch_imsg(int fd, int event, void *bula) control_state.tx = -1; imsg_compose_event(&c->iev, IMSG_CTL_COMMIT, 0, 0, -1, NULL, 0); - control_notify(imsg.hdr.type); + control_notify(type); break; case IMSG_CTL_MONITOR: c->monitor = 1; @@ -436,7 +437,7 @@ control_dispatch_imsg(int fd, int event, void *bula) break; default: log_debug("%s: error handling imsg %d", __func__, - imsg.hdr.type); + type); break; } imsg_free(&imsg); blob - cb65f159136ceeccc6d056e7c9214215f8d47380 blob + 16543ad20e771d630584f1653c5eff4e4bb0ab73 --- ctl.c +++ ctl.c @@ -364,7 +364,7 @@ ctlaction(struct parse_result *res) struct player_status ps; struct player_event ev; ssize_t n; - int i, ret = 0, done = 1; + int i, type, ret = 0, done = 1; if (pledge("stdio", NULL) == -1) fatal("pledge"); @@ -491,7 +491,8 @@ ctlaction(struct parse_result *res) if (n == 0) break; - if (imsg.hdr.type == IMSG_CTL_ERR) { + type = imsg_get_type(&imsg); + if (type == IMSG_CTL_ERR) { log_warnx("%s: %s", res->ctl->name, imsg_strerror(&imsg)); ret = 1; @@ -505,11 +506,10 @@ ctlaction(struct parse_result *res) fatalx("received more replies than " "files enqueued."); - if (imsg.hdr.type == IMSG_CTL_ADD) + if (type == IMSG_CTL_ADD) log_debug("enqueued %s", res->files[i]); else - fatalx("invalid message %d", - imsg.hdr.type); + fatalx("invalid message %d", type); i++; done = res->files[i] == NULL; break; @@ -538,9 +538,8 @@ ctlaction(struct parse_result *res) case PREV: case JUMP: case MODE: - if (imsg.hdr.type != IMSG_CTL_STATUS) - fatalx("invalid message %d", - imsg.hdr.type); + if (type != IMSG_CTL_STATUS) + fatalx("invalid message %d", type); if (imsg_get_data(&imsg, &ps, sizeof(ps)) == -1) @@ -552,23 +551,21 @@ ctlaction(struct parse_result *res) done = 1; break; case LOAD: - if (imsg.hdr.type == IMSG_CTL_ADD) + if (type == IMSG_CTL_ADD) break; - if (imsg.hdr.type == IMSG_CTL_COMMIT) { + if (type == IMSG_CTL_COMMIT) { done = 1; break; } - if (imsg.hdr.type != IMSG_CTL_BEGIN) - fatalx("invalid message %d", - imsg.hdr.type); + if (type != IMSG_CTL_BEGIN) + fatalx("invalid message %d", type); load_files(res, &ret); break; case MONITOR: - if (imsg.hdr.type != IMSG_CTL_MONITOR) - fatalx("invalid message %d", - imsg.hdr.type); + if (type != IMSG_CTL_MONITOR) + fatalx("invalid message %d", type); if (imsg_get_data(&imsg, &ev, sizeof(ev)) == -1) blob - d2fa07383cb9896a506c41bbc846138abd7ff922 blob + 5ca6497f73a36227c35a738c90f86d3bedda2769 --- player.c +++ player.c @@ -125,8 +125,8 @@ again: goto again; } - ret = imsg.hdr.type; - switch (imsg.hdr.type) { + ret = imsg_get_type(&imsg); + switch (ret) { case IMSG_PLAY: if (nextfd != -1) fatalx("track already enqueued"); @@ -154,7 +154,7 @@ again: *s = 0; break; default: - fatalx("unknown imsg %d", imsg.hdr.type); + fatalx("unknown imsg %d", ret); } imsg_free(&imsg); blob - 77c66abdeb8de47549a767232c6a8ff8264bdfdc blob + b6888f4d5f07b6e4310164980fc32c0d3a82f9be --- web/web.c +++ web/web.c @@ -466,7 +466,7 @@ imsg_dispatch(int fd, int ev, void *d) datalen = IMSG_DATA_SIZE(imsg); - switch (imsg.hdr.type) { + switch (imsg_get_type(&imsg)) { case IMSG_CTL_ERR: if (imsg_get_ibuf(&imsg, &ibuf) == -1 || (datalen = ibuf_size(&ibuf)) == 0 ||