2 * Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 extern struct sio_hdl *hdl;
25 extern struct imsgev *iev_player;
27 #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
30 IMSG_PLAY, /* fd + filename */
37 IMSG_CTL_PLAY, /* with optional filename */
48 IMSG_CTL_REPEAT, /* struct player_repeat */
51 IMSG_CTL_ADD, /* path to a file */
52 IMSG_CTL_COMMIT, /* offset of the track to jump to */
61 void (*handler)(int, short, void *);
87 struct player_repeat {
92 struct player_status {
95 struct player_repeat rp;
103 struct player_repeat rep;
104 struct ctl_command *ctl;
110 int (*main)(struct parse_result *, int, char **);
118 void spawn_daemon(void);
119 void imsg_event_add(struct imsgev *iev);
120 int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
121 pid_t, int, const void *, uint16_t);
122 int main_send_player(uint16_t, int, const void *, uint16_t);
123 int main_play_song(const char *);
124 void main_playlist_jump(struct imsgev *, struct imsg *);
125 void main_playlist_resume(void);
126 void main_playlist_advance(void);
127 void main_playlist_previous(void);
128 void main_restart_track(void);
129 void main_senderr(struct imsgev *, const char *);
130 void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
131 void main_send_playlist(struct imsgev *);
132 void main_send_status(struct imsgev *);
135 __dead void usage(void);
136 __dead void ctl(int, char **);
139 int player_setup(int, int, int);
140 void player_senderr(void);
141 void player_sendeof(void);
142 int player_shouldstop(void);
143 int player(int, int);
145 void play_oggvorbis(int fd);
146 void play_mp3(int fd);
147 void play_flac(int fd);
148 void play_opus(int fd);