Commit Diff


commit - 93cde5d11223ff70e3ced414173b32a63790c972
commit + 3dd907310bab777213b20bd814d72faba91e40ae
blob - a2aae07b18f8dce0457f2850ee368e6509b68854
blob + fc49a771a10bbb1a9f2e3fa8767085c0d51fe99b
--- amused.h
+++ amused.h
@@ -52,7 +52,7 @@ enum imsg_type {
 	IMSG_CTL_ADD,		/* path to a file */
 	IMSG_CTL_COMMIT,	/* offset of the track to jump to */
 
-	IMSG_CTL_MONITOR,
+	IMSG_CTL_MONITOR,	/* struct player_event */
 
 	IMSG_CTL_ERR,
 	IMSG__LAST,
@@ -111,6 +111,13 @@ struct player_status {
 	struct player_mode	mode;
 };
 
+struct player_event {
+	int			 event;
+	int64_t			 position;
+	int64_t			 duration;
+	struct player_mode	 mode;
+};
+
 struct parse_result {
 	enum actions		 action;
 	char			**files;
blob - 5e55431278797c63ebc65903c651f19a3c4f01a7
blob + 52cf16aab058533b40f3246173af02bc7ec63ae5
--- control.c
+++ control.c
@@ -230,13 +230,22 @@ void
 control_notify(int type)
 {
 	struct ctl_conn *c;
+	struct player_event ev;
 
+	memset(&ev, 0, sizeof(ev));
+	ev.event = type;
+	ev.position = current_position;
+	ev.duration = current_duration;
+	ev.mode.repeat_one = repeat_one;
+	ev.mode.repeat_all = repeat_all;
+	ev.mode.consume = consume;
+
 	TAILQ_FOREACH(c, &ctl_conns, entry) {
 		if (!c->monitor)
 			continue;
 
 		imsg_compose_event(&c->iev, IMSG_CTL_MONITOR, 0, 0,
-		    -1, &type, sizeof(type));
+		    -1, &ev, sizeof(ev));
 	}
 }
 
blob - 0f93fc87725e69581f0926e709b777ceb95be916
blob + e00ed2c62c691a8bc1b83ec4f671b82087eaba08
--- ctl.c
+++ ctl.c
@@ -329,15 +329,39 @@ print_status(struct player_status *ps, const char *spe
 	free(dup);
 }
 
+static void
+print_monitor_event(struct player_event *ev)
+{
+	switch (ev->event) {
+	case IMSG_CTL_MODE:
+		printf("%s repeat one:%s all:%s consume:%s\n",
+		    event_name(ev->event),
+		    ev->mode.repeat_one ? "on" : "off",
+		    ev->mode.repeat_all ? "on" : "off",
+		    ev->mode.consume ? "on" : "off");
+		break;
+	case IMSG_CTL_SEEK:
+		printf("%s %lld %lld\n", event_name(ev->event),
+		    (long long)ev->position, (long long)ev->duration);
+		break;
+	default:
+		puts(event_name(ev->event));
+		break;
+	}
+
+	fflush(stdout);
+}
+
 static int
 ctlaction(struct parse_result *res)
 {
 	char path[PATH_MAX];
 	struct imsg imsg;
 	struct player_status ps;
+	struct player_event ev;
 	size_t datalen;
 	ssize_t n;
-	int i, type, ret = 0, done = 1;
+	int i, ret = 0, done = 1;
 
 	if (pledge("stdio", NULL) == -1)
 		fatal("pledge");
@@ -543,18 +567,17 @@ ctlaction(struct parse_result *res)
 					fatalx("invalid message %d",
 					    imsg.hdr.type);
 
-				if (datalen != sizeof(type))
+				if (datalen != sizeof(ev))
 					fatalx("data size mismatch");
 
-				memcpy(&type, imsg.data, sizeof(type));
-				if (type < 0 || type > IMSG__LAST)
+				memcpy(&ev, imsg.data, sizeof(ev));
+				if (ev.event < 0 || ev.event > IMSG__LAST)
 					fatalx("received corrupted data");
 
-				if (!res->monitor[type])
+				if (!res->monitor[ev.event])
 					break;
 
-				puts(event_name(type));
-				fflush(stdout);
+				print_monitor_event(&ev);
 				break;
 			default:
 				done = 1;