2 3baa2617 2022-02-16 op * Copyright (c) 2022 Omar Polo <op@openbsd.org>
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.
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.
17 3baa2617 2022-02-16 op #ifndef AMUSED_H
18 3baa2617 2022-02-16 op #define AMUSED_H
20 3baa2617 2022-02-16 op extern char *csock;
21 3baa2617 2022-02-16 op extern int debug;
22 3baa2617 2022-02-16 op extern int verbose;
23 3baa2617 2022-02-16 op extern int playing;
24 3baa2617 2022-02-16 op extern struct imsgev *iev_player;
26 3baa2617 2022-02-16 op #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
28 3baa2617 2022-02-16 op enum imsg_type {
29 3baa2617 2022-02-16 op IMSG_PLAY, /* fd + filename */
36 17ef54d6 2022-06-22 op IMSG_ERR, /* error string */
38 a913de21 2022-02-17 op IMSG_CTL_PLAY, /* with optional filename */
39 3baa2617 2022-02-16 op IMSG_CTL_TOGGLE_PLAY,
40 3baa2617 2022-02-16 op IMSG_CTL_PAUSE,
41 3baa2617 2022-02-16 op IMSG_CTL_STOP,
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 9fb94242 2022-07-13 op IMSG_CTL_MODE, /* struct player_mode */
49 791d3db3 2022-07-09 op IMSG_CTL_SEEK, /* struct player_seek */
51 19d6b480 2022-02-17 op IMSG_CTL_BEGIN,
52 19d6b480 2022-02-17 op IMSG_CTL_ADD, /* path to a file */
53 3af93963 2022-03-02 op IMSG_CTL_COMMIT, /* offset of the track to jump to */
55 87f575c3 2022-02-21 op IMSG_CTL_MONITOR,
61 3baa2617 2022-02-16 op struct imsgev {
62 3baa2617 2022-02-16 op struct imsgbuf ibuf;
63 3baa2617 2022-02-16 op void (*handler)(int, short, void *);
64 3baa2617 2022-02-16 op struct event ev;
68 3baa2617 2022-02-16 op enum actions {
74 8d087670 2022-07-09 op RESTART, /* seek to zero */
88 791d3db3 2022-07-09 op struct player_seek {
89 791d3db3 2022-07-09 op int64_t offset;
94 3baa2617 2022-02-16 op struct ctl_command;
96 9881c98c 2022-07-13 op #define MODE_ON +1
97 9881c98c 2022-07-13 op #define MODE_OFF 0
98 9881c98c 2022-07-13 op #define MODE_UNDEF -1
99 9881c98c 2022-07-13 op #define MODE_TOGGLE -2
100 9fb94242 2022-07-13 op struct player_mode {
101 310ef57c 2022-02-19 op int repeat_one;
102 310ef57c 2022-02-19 op int repeat_all;
106 44398779 2022-02-19 op struct player_status {
107 44398779 2022-02-19 op char path[PATH_MAX];
109 ff06024f 2022-07-08 op int64_t position;
110 ff06024f 2022-07-08 op int64_t duration;
111 9fb94242 2022-07-13 op struct player_mode mode;
114 3baa2617 2022-02-16 op struct parse_result {
115 3baa2617 2022-02-16 op enum actions action;
116 3baa2617 2022-02-16 op char **files;
119 90122a37 2022-05-14 op int monitor[IMSG__LAST];
120 9fb94242 2022-07-13 op struct player_mode mode;
121 791d3db3 2022-07-09 op struct player_seek seek;
122 68e4f29e 2022-07-10 op const char *status_format;
123 3baa2617 2022-02-16 op struct ctl_command *ctl;
126 3baa2617 2022-02-16 op struct ctl_command {
127 3baa2617 2022-02-16 op const char *name;
128 3baa2617 2022-02-16 op enum actions action;
129 3baa2617 2022-02-16 op int (*main)(struct parse_result *, int, char **);
130 3baa2617 2022-02-16 op const char *usage;
133 19d6b480 2022-02-17 op struct playlist;
135 3baa2617 2022-02-16 op /* amused.c */
136 fea541a8 2022-02-16 op void spawn_daemon(void);
137 3baa2617 2022-02-16 op void imsg_event_add(struct imsgev *iev);
138 3baa2617 2022-02-16 op int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
139 3baa2617 2022-02-16 op pid_t, int, const void *, uint16_t);
140 791d3db3 2022-07-09 op int main_send_player(uint16_t, int, const void *, size_t);
141 f3bd773b 2022-02-19 op int main_play_song(const char *);
142 a913de21 2022-02-17 op void main_playlist_jump(struct imsgev *, struct imsg *);
143 2f589330 2022-02-17 op void main_playlist_resume(void);
144 aaccc123 2022-02-16 op void main_playlist_advance(void);
145 af27e631 2022-02-17 op void main_playlist_previous(void);
146 19d6b480 2022-02-17 op void main_senderr(struct imsgev *, const char *);
147 19d6b480 2022-02-17 op void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
148 d980494c 2022-02-16 op void main_send_playlist(struct imsgev *);
149 bb3f279f 2022-02-16 op void main_send_status(struct imsgev *);
150 15aecb89 2022-07-12 op void main_seek(struct player_seek *);
153 3baa2617 2022-02-16 op __dead void usage(void);
154 3baa2617 2022-02-16 op __dead void ctl(int, char **);
156 3baa2617 2022-02-16 op /* player.c */
157 b9d2a697 2022-07-08 op int player_setup(unsigned int, unsigned int, unsigned int);
158 ff06024f 2022-07-08 op void player_setduration(int64_t);
159 791d3db3 2022-07-09 op void player_setpos(int64_t);
160 791d3db3 2022-07-09 op int play(const void *, size_t, int64_t *);
161 3baa2617 2022-02-16 op int player(int, int);
163 17ef54d6 2022-06-22 op int play_oggvorbis(int, const char **);
164 17ef54d6 2022-06-22 op int play_mp3(int, const char **);
165 17ef54d6 2022-06-22 op int play_flac(int, const char **);
166 17ef54d6 2022-06-22 op int play_opus(int, const char **);