Blame


1 3baa2617 2022-02-16 op /*
2 3baa2617 2022-02-16 op * Copyright (c) 2022 Omar Polo <op@openbsd.org>
3 3baa2617 2022-02-16 op *
4 3baa2617 2022-02-16 op * Permission to use, copy, modify, and distribute this software for any
5 3baa2617 2022-02-16 op * purpose with or without fee is hereby granted, provided that the above
6 3baa2617 2022-02-16 op * copyright notice and this permission notice appear in all copies.
7 3baa2617 2022-02-16 op *
8 3baa2617 2022-02-16 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 3baa2617 2022-02-16 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 3baa2617 2022-02-16 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 3baa2617 2022-02-16 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 3baa2617 2022-02-16 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 3baa2617 2022-02-16 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 3baa2617 2022-02-16 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 3baa2617 2022-02-16 op */
16 3baa2617 2022-02-16 op
17 3baa2617 2022-02-16 op #ifndef AMUSED_H
18 3baa2617 2022-02-16 op #define AMUSED_H
19 3baa2617 2022-02-16 op
20 3baa2617 2022-02-16 op extern struct sio_hdl *hdl;
21 3baa2617 2022-02-16 op extern char *csock;
22 3baa2617 2022-02-16 op extern int debug;
23 3baa2617 2022-02-16 op extern int verbose;
24 3baa2617 2022-02-16 op extern int playing;
25 3baa2617 2022-02-16 op extern struct imsgev *iev_player;
26 3baa2617 2022-02-16 op
27 3baa2617 2022-02-16 op #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
28 3baa2617 2022-02-16 op
29 3baa2617 2022-02-16 op enum imsg_type {
30 3baa2617 2022-02-16 op IMSG_PLAY, /* fd + filename */
31 3baa2617 2022-02-16 op IMSG_RESUME,
32 3baa2617 2022-02-16 op IMSG_PAUSE,
33 3baa2617 2022-02-16 op IMSG_STOP,
34 3baa2617 2022-02-16 op IMSG_EOF,
35 3baa2617 2022-02-16 op IMSG_ERR,
36 3baa2617 2022-02-16 op
37 a913de21 2022-02-17 op IMSG_CTL_PLAY, /* with optional filename */
38 3baa2617 2022-02-16 op IMSG_CTL_TOGGLE_PLAY,
39 3baa2617 2022-02-16 op IMSG_CTL_PAUSE,
40 3baa2617 2022-02-16 op IMSG_CTL_STOP,
41 3baa2617 2022-02-16 op IMSG_CTL_RESTART,
42 3baa2617 2022-02-16 op IMSG_CTL_FLUSH,
43 3baa2617 2022-02-16 op IMSG_CTL_SHOW,
44 bb3f279f 2022-02-16 op IMSG_CTL_STATUS,
45 af27e631 2022-02-17 op IMSG_CTL_NEXT,
46 af27e631 2022-02-17 op IMSG_CTL_PREV,
47 a913de21 2022-02-17 op IMSG_CTL_JUMP,
48 310ef57c 2022-02-19 op IMSG_CTL_REPEAT, /* struct player_repeat */
49 3baa2617 2022-02-16 op
50 19d6b480 2022-02-17 op IMSG_CTL_BEGIN,
51 19d6b480 2022-02-17 op IMSG_CTL_ADD, /* path to a file */
52 19d6b480 2022-02-17 op IMSG_CTL_COMMIT,
53 19d6b480 2022-02-17 op
54 3baa2617 2022-02-16 op IMSG_CTL_ERR,
55 3baa2617 2022-02-16 op };
56 3baa2617 2022-02-16 op
57 3baa2617 2022-02-16 op struct imsgev {
58 3baa2617 2022-02-16 op struct imsgbuf ibuf;
59 3baa2617 2022-02-16 op void (*handler)(int, short, void *);
60 3baa2617 2022-02-16 op struct event ev;
61 3baa2617 2022-02-16 op short events;
62 3baa2617 2022-02-16 op };
63 3baa2617 2022-02-16 op
64 3baa2617 2022-02-16 op enum actions {
65 3baa2617 2022-02-16 op NONE,
66 3baa2617 2022-02-16 op PLAY,
67 3baa2617 2022-02-16 op PAUSE,
68 3baa2617 2022-02-16 op TOGGLE,
69 3baa2617 2022-02-16 op STOP,
70 3baa2617 2022-02-16 op RESTART,
71 3baa2617 2022-02-16 op ADD,
72 3baa2617 2022-02-16 op FLUSH,
73 3baa2617 2022-02-16 op SHOW,
74 bb3f279f 2022-02-16 op STATUS,
75 af27e631 2022-02-17 op PREV,
76 af27e631 2022-02-17 op NEXT,
77 14be015f 2022-02-17 op LOAD,
78 a913de21 2022-02-17 op JUMP,
79 310ef57c 2022-02-19 op REPEAT,
80 3baa2617 2022-02-16 op };
81 3baa2617 2022-02-16 op
82 3baa2617 2022-02-16 op struct ctl_command;
83 3baa2617 2022-02-16 op
84 310ef57c 2022-02-19 op struct player_repeat {
85 310ef57c 2022-02-19 op int repeat_one;
86 310ef57c 2022-02-19 op int repeat_all;
87 310ef57c 2022-02-19 op };
88 310ef57c 2022-02-19 op
89 44398779 2022-02-19 op struct player_status {
90 44398779 2022-02-19 op char path[PATH_MAX];
91 44398779 2022-02-19 op int status;
92 44398779 2022-02-19 op struct player_repeat rp;
93 44398779 2022-02-19 op };
94 44398779 2022-02-19 op
95 3baa2617 2022-02-16 op struct parse_result {
96 3baa2617 2022-02-16 op enum actions action;
97 3baa2617 2022-02-16 op char **files;
98 ec1fb0c7 2022-02-17 op const char *file;
99 8e916714 2022-02-17 op int pretty;
100 310ef57c 2022-02-19 op struct player_repeat rep;
101 3baa2617 2022-02-16 op struct ctl_command *ctl;
102 3baa2617 2022-02-16 op };
103 3baa2617 2022-02-16 op
104 3baa2617 2022-02-16 op struct ctl_command {
105 3baa2617 2022-02-16 op const char *name;
106 3baa2617 2022-02-16 op enum actions action;
107 3baa2617 2022-02-16 op int (*main)(struct parse_result *, int, char **);
108 3baa2617 2022-02-16 op const char *usage;
109 3baa2617 2022-02-16 op int has_pledge;
110 3baa2617 2022-02-16 op };
111 3baa2617 2022-02-16 op
112 19d6b480 2022-02-17 op struct playlist;
113 19d6b480 2022-02-17 op
114 3baa2617 2022-02-16 op /* amused.c */
115 fea541a8 2022-02-16 op void spawn_daemon(void);
116 3baa2617 2022-02-16 op void imsg_event_add(struct imsgev *iev);
117 3baa2617 2022-02-16 op int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
118 3baa2617 2022-02-16 op pid_t, int, const void *, uint16_t);
119 06961b72 2022-02-16 op int main_send_player(uint16_t, int, const void *, uint16_t);
120 f3bd773b 2022-02-19 op int main_play_song(const char *);
121 a913de21 2022-02-17 op void main_playlist_jump(struct imsgev *, struct imsg *);
122 2f589330 2022-02-17 op void main_playlist_resume(void);
123 aaccc123 2022-02-16 op void main_playlist_advance(void);
124 af27e631 2022-02-17 op void main_playlist_previous(void);
125 aaccc123 2022-02-16 op void main_restart_track(void);
126 19d6b480 2022-02-17 op void main_senderr(struct imsgev *, const char *);
127 19d6b480 2022-02-17 op void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
128 d980494c 2022-02-16 op void main_send_playlist(struct imsgev *);
129 bb3f279f 2022-02-16 op void main_send_status(struct imsgev *);
130 3baa2617 2022-02-16 op
131 3baa2617 2022-02-16 op /* ctl.c */
132 3baa2617 2022-02-16 op __dead void usage(void);
133 3baa2617 2022-02-16 op __dead void ctl(int, char **);
134 3baa2617 2022-02-16 op
135 3baa2617 2022-02-16 op /* player.c */
136 e24324f1 2022-02-21 op int player_setup(int, int, int);
137 3baa2617 2022-02-16 op void player_senderr(void);
138 3baa2617 2022-02-16 op void player_sendeof(void);
139 3baa2617 2022-02-16 op int player_shouldstop(void);
140 3baa2617 2022-02-16 op int player(int, int);
141 3baa2617 2022-02-16 op
142 3baa2617 2022-02-16 op void play_oggvorbis(int fd);
143 3baa2617 2022-02-16 op void play_mp3(int fd);
144 3baa2617 2022-02-16 op void play_flac(int fd);
145 3baa2617 2022-02-16 op void play_opus(int fd);
146 3baa2617 2022-02-16 op
147 3baa2617 2022-02-16 op #endif