commit - 5c9741443b589c7f51dc66ae1b0e0c8708e85f69
commit + ddaffed69d4fe7f814777d57bc373b2a40d4abb7
blob - b4c6b13bb50662e21b5c2c07350b4534676818f0
blob + 9d24e5b56fc0a49727e701d8d733c4e1b57d0ecb
--- amused.c
+++ amused.c
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)
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
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);
if (n == 0)
break;
- switch (imsg.hdr.type) {
+ switch (type = imsg_get_type(&imsg)) {
case IMSG_CTL_PLAY:
switch (play_state) {
case STATE_STOPPED:
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) {
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();
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;
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) {
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) {
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;
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
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");
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;
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;
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)
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
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");
*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
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 ||