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.
24 extern struct imsgev *iev_player;
26 #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
29 IMSG_PLAY, /* fd + filename */
36 IMSG_ERR, /* error string */
38 IMSG_CTL_PLAY, /* with optional filename */
48 IMSG_CTL_MODE, /* struct player_mode */
49 IMSG_CTL_SEEK, /* struct player_seek */
52 IMSG_CTL_ADD, /* path to a file */
53 IMSG_CTL_COMMIT, /* offset of the track to jump to */
63 void (*handler)(int, short, void *);
74 RESTART, /* seek to zero */
99 #define MODE_TOGGLE -2
106 struct player_status {
111 struct player_mode mode;
114 struct parse_result {
119 int monitor[IMSG__LAST];
120 struct player_mode mode;
121 struct player_seek seek;
122 const char *status_format;
123 struct ctl_command *ctl;
129 int (*main)(struct parse_result *, int, char **);
136 void spawn_daemon(void);
137 void imsg_event_add(struct imsgev *iev);
138 int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
139 pid_t, int, const void *, uint16_t);
140 int main_send_player(uint16_t, int, const void *, size_t);
141 int main_play_song(const char *);
142 void main_playlist_jump(struct imsgev *, struct imsg *);
143 void main_playlist_resume(void);
144 void main_playlist_advance(void);
145 void main_playlist_previous(void);
146 void main_senderr(struct imsgev *, const char *);
147 void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
148 void main_send_playlist(struct imsgev *);
149 void main_send_status(struct imsgev *);
150 void main_seek(struct player_seek *);
153 __dead void usage(void);
154 __dead void ctl(int, char **);
157 int player_setup(unsigned int, unsigned int, unsigned int);
158 void player_setduration(int64_t);
159 void player_setpos(int64_t);
160 int play(const void *, size_t, int64_t *);
161 int player(int, int);
163 int play_oggvorbis(int, const char **);
164 int play_mp3(int, const char **);
165 int play_flac(int, const char **);
166 int play_opus(int, const char **);