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 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;
27 3baa2617 2022-02-16 op #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
29 3baa2617 2022-02-16 op enum imsg_type {
30 3baa2617 2022-02-16 op IMSG_PLAY, /* fd + filename */
37 3baa2617 2022-02-16 op IMSG_CTL_PLAY,
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,
48 19d6b480 2022-02-17 op IMSG_CTL_BEGIN,
49 19d6b480 2022-02-17 op IMSG_CTL_ADD, /* path to a file */
50 19d6b480 2022-02-17 op IMSG_CTL_COMMIT,
55 3baa2617 2022-02-16 op struct imsgev {
56 3baa2617 2022-02-16 op struct imsgbuf ibuf;
57 3baa2617 2022-02-16 op void (*handler)(int, short, void *);
58 3baa2617 2022-02-16 op struct event ev;
62 3baa2617 2022-02-16 op enum actions {
78 3baa2617 2022-02-16 op struct ctl_command;
80 3baa2617 2022-02-16 op struct parse_result {
81 3baa2617 2022-02-16 op enum actions action;
84 3baa2617 2022-02-16 op struct ctl_command *ctl;
87 3baa2617 2022-02-16 op struct ctl_command {
88 3baa2617 2022-02-16 op const char *name;
89 3baa2617 2022-02-16 op enum actions action;
90 3baa2617 2022-02-16 op int (*main)(struct parse_result *, int, char **);
91 3baa2617 2022-02-16 op const char *usage;
92 3baa2617 2022-02-16 op int has_pledge;
95 bb3f279f 2022-02-16 op struct player_status {
96 bb3f279f 2022-02-16 op char path[PATH_MAX];
100 19d6b480 2022-02-17 op struct playlist;
102 3baa2617 2022-02-16 op /* amused.c */
103 fea541a8 2022-02-16 op void spawn_daemon(void);
104 3baa2617 2022-02-16 op void imsg_event_add(struct imsgev *iev);
105 3baa2617 2022-02-16 op int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
106 3baa2617 2022-02-16 op pid_t, int, const void *, uint16_t);
107 06961b72 2022-02-16 op int main_send_player(uint16_t, int, const void *, uint16_t);
108 2f589330 2022-02-17 op void main_playlist_resume(void);
109 aaccc123 2022-02-16 op void main_playlist_advance(void);
110 af27e631 2022-02-17 op void main_playlist_previous(void);
111 aaccc123 2022-02-16 op void main_restart_track(void);
112 19d6b480 2022-02-17 op void main_senderr(struct imsgev *, const char *);
113 19d6b480 2022-02-17 op void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
114 d980494c 2022-02-16 op void main_send_playlist(struct imsgev *);
115 bb3f279f 2022-02-16 op void main_send_status(struct imsgev *);
118 3baa2617 2022-02-16 op __dead void usage(void);
119 3baa2617 2022-02-16 op __dead void ctl(int, char **);
121 3baa2617 2022-02-16 op /* player.c */
122 3baa2617 2022-02-16 op int player_setrate(int);
123 3baa2617 2022-02-16 op void player_senderr(void);
124 3baa2617 2022-02-16 op void player_sendeof(void);
125 3baa2617 2022-02-16 op int player_shouldstop(void);
126 3baa2617 2022-02-16 op int player(int, int);
128 3baa2617 2022-02-16 op void play_oggvorbis(int fd);
129 3baa2617 2022-02-16 op void play_mp3(int fd);
130 3baa2617 2022-02-16 op void play_flac(int fd);
131 3baa2617 2022-02-16 op void play_opus(int fd);