Commit Diff


commit - 8544abcd4a1bf2bfd027aa1fe4a458f07f794737
commit + 06961b726d45e79b997a702b3218f146e332415c
blob - 1c24940ec5b8a99e1ee2315338d28155e7e8dcd4
blob + 788ef4361dcf20851dd5a2a13d271468d57a9fe9
--- amused.c
+++ amused.c
@@ -362,6 +362,12 @@ imsg_compose_event(struct imsgev *iev, uint16_t type, 
 		imsg_event_add(iev);
 
 	return ret;
+}
+
+int
+main_send_player(uint16_t type, int fd, const void *data, uint16_t datalen)
+{
+	return imsg_compose_event(iev_player, type, 0, 0, fd, data, datalen);
 }
 
 int
blob - 5d76e295c518c59a068d76bdf4f4155a26ef40d9
blob + f6be8f6fce8a4df8e049ac58e182443f25ae99c3
--- amused.h
+++ amused.h
@@ -85,6 +85,7 @@ struct ctl_command {
 void		imsg_event_add(struct imsgev *iev);
 int		imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
 		    pid_t, int, const void *, uint16_t);
+int		main_send_player(uint16_t, int, const void *, uint16_t);
 int		main_play_song(const char *);
 void		main_enqueue(struct imsgev *, struct imsg *);
 
blob - e24d6d2b6d90d0cd9c303969532e5eafc0c71fe5
blob + 77c3382220691b28d685ac3ef8b30bc8e0398238
--- control.c
+++ control.c
@@ -265,8 +265,7 @@ control_dispatch_imsg(int fd, short event, void *bula)
 				/* do nothing */
 				break;
 			case STATE_PAUSED:
-				imsg_compose_event(iev_player, IMSG_RESUME,
-				    0, 0, -1, NULL, 0);
+				main_send_player(IMSG_RESUME, -1, NULL, 0);
 				break;
 			}
 			break;
@@ -280,27 +279,25 @@ control_dispatch_imsg(int fd, short event, void *bula)
 				main_play_song(song);
 				break;
 			case STATE_PLAYING:
-				imsg_compose_event(iev_player, IMSG_PAUSE, 0, 0, -1,
-				    NULL, 0);
+				main_send_player(IMSG_PAUSE, -1, NULL, 0);
 				break;
 			case STATE_PAUSED:
-				imsg_compose_event(iev_player, IMSG_RESUME, 0, 0, -1,
-				    NULL, 0);
+				main_send_player(IMSG_RESUME, -1, NULL, 0);
 				break;
 			}
 			break;
 		case IMSG_CTL_PAUSE:
 			if (play_state != STATE_PLAYING)
 				break;
-			imsg_compose_event(iev_player, IMSG_PAUSE, 0, 0, -1, NULL, 0);
+			main_send_player(IMSG_PAUSE, -1, NULL, 0);
 			break;
 		case IMSG_CTL_STOP:
 			if (play_state == STATE_STOPPED)
 				break;
-			imsg_compose_event(iev_player, IMSG_STOP, 0, 0, -1, NULL, 0);
+			main_send_player(IMSG_STOP, -1, NULL, 0);
 			break;
 		case IMSG_CTL_RESTART:
-			imsg_compose_event(iev_player, IMSG_STOP, 0, 0, -1, NULL, 0);
+			main_send_player(IMSG_STOP, -1, NULL, 0);
 			song = playlist_current();
 			if (song == NULL)
 				break;