-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathamused.h
166 lines (145 loc) · 3.56 KB
/
amused.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) 2022, 2023 Omar Polo <op@omarpolo.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef AMUSED_H
#define AMUSED_H
extern char *csock;
extern int debug;
extern int verbose;
extern int playing;
extern struct imsgev *iev_player;
#define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
enum imsg_type {
IMSG_PLAY, /* fd + filename */
IMSG_RESUME,
IMSG_PAUSE,
IMSG_STOP,
IMSG_POS,
IMSG_LEN,
IMSG_EOF,
IMSG_ERR, /* error string */
IMSG_CTL_PLAY, /* with optional filename */
IMSG_CTL_TOGGLE_PLAY,
IMSG_CTL_PAUSE,
IMSG_CTL_STOP,
IMSG_CTL_FLUSH,
IMSG_CTL_SHOW,
IMSG_CTL_STATUS,
IMSG_CTL_NEXT,
IMSG_CTL_PREV,
IMSG_CTL_JUMP,
IMSG_CTL_MODE, /* struct player_mode */
IMSG_CTL_SEEK, /* struct player_seek */
IMSG_CTL_SHUFFLE, /* int all */
IMSG_CTL_BEGIN,
IMSG_CTL_ADD, /* path to a file */
IMSG_CTL_COMMIT, /* offset of the track to jump to */
IMSG_CTL_MONITOR, /* struct player_event */
IMSG_CTL_ERR,
IMSG__LAST,
};
struct imsgev {
struct imsgbuf imsgbuf;
void (*handler)(int, int, void *);
int events;
};
enum actions {
NONE,
PLAY,
PAUSE,
TOGGLE,
STOP,
RESTART, /* seek to zero */
ADD,
FLUSH,
SHOW,
STATUS,
PREV,
NEXT,
LOAD,
JUMP,
MODE,
MONITOR,
SEEK,
SHUFFLE,
};
struct player_seek {
int64_t offset;
int relative;
int percent;
};
struct ctl_command;
#define MODE_ON +1
#define MODE_OFF 0
#define MODE_UNDEF -1
#define MODE_TOGGLE -2
struct player_mode {
int repeat_one;
int repeat_all;
int consume;
};
struct player_status {
char path[PATH_MAX];
int status;
int64_t position;
int64_t duration;
struct player_mode mode;
};
struct player_event {
int event;
int64_t position;
int64_t duration;
struct player_mode mode;
};
struct parse_result {
enum actions action;
char **files;
FILE *fp;
int all;
int pretty;
int monitor[IMSG__LAST];
struct player_mode mode;
struct player_seek seek;
const char *status_format;
struct ctl_command *ctl;
};
struct ctl_command {
const char *name;
enum actions action;
int (*main)(struct parse_result *, int, char **);
const char *usage;
};
struct playlist;
struct pollfd;
/* amused.c */
void spawn_daemon(void);
void imsg_event_add(struct imsgev *iev);
int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
pid_t, int, const void *, uint16_t);
int main_send_player(uint16_t, int, const void *, size_t);
int main_play_song(const char *);
void main_playlist_jump(struct imsgev *, struct imsg *);
void main_playlist_resume(void);
void main_playlist_advance(void);
void main_playlist_previous(void);
void main_senderr(struct imsgev *, const char *);
void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
void main_send_playlist(struct imsgev *);
void main_send_status(struct imsgev *);
void main_seek(struct player_seek *);
/* ctl.c */
__dead void usage(void);
__dead void ctl(int, char **);
#endif