Blame
Date:
Wed Mar 9 09:13:06 2022 UTC
Message:
refactor the player_shouldstop/sio_write dance in a function
001
2022-02-16
op
/*
002
2022-02-16
op
* Copyright (c) 2022 Omar Polo <op@openbsd.org>
003
2022-02-16
op
*
004
2022-02-16
op
* Permission to use, copy, modify, and distribute this software for any
005
2022-02-16
op
* purpose with or without fee is hereby granted, provided that the above
006
2022-02-16
op
* copyright notice and this permission notice appear in all copies.
007
2022-02-16
op
*
008
2022-02-16
op
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
009
2022-02-16
op
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
010
2022-02-16
op
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
011
2022-02-16
op
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
012
2022-02-16
op
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
013
2022-02-16
op
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
014
2022-02-16
op
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
015
2022-02-16
op
*/
016
2022-02-16
op
017
2022-02-16
op
#ifndef AMUSED_H
018
2022-02-16
op
#define AMUSED_H
019
2022-02-16
op
020
2022-02-16
op
extern struct sio_hdl *hdl;
021
2022-02-16
op
extern char *csock;
022
2022-02-16
op
extern int debug;
023
2022-02-16
op
extern int verbose;
024
2022-02-16
op
extern int playing;
025
2022-02-16
op
extern struct imsgev *iev_player;
026
2022-02-16
op
027
2022-02-16
op
#define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
028
2022-02-16
op
029
2022-02-16
op
enum imsg_type {
030
2022-02-16
op
IMSG_PLAY, /* fd + filename */
031
2022-02-16
op
IMSG_RESUME,
032
2022-02-16
op
IMSG_PAUSE,
033
2022-02-16
op
IMSG_STOP,
034
2022-02-16
op
IMSG_EOF,
035
2022-02-16
op
IMSG_ERR,
036
2022-02-16
op
037
2022-02-17
op
IMSG_CTL_PLAY, /* with optional filename */
038
2022-02-16
op
IMSG_CTL_TOGGLE_PLAY,
039
2022-02-16
op
IMSG_CTL_PAUSE,
040
2022-02-16
op
IMSG_CTL_STOP,
041
2022-02-16
op
IMSG_CTL_RESTART,
042
2022-02-16
op
IMSG_CTL_FLUSH,
043
2022-02-16
op
IMSG_CTL_SHOW,
044
2022-02-16
op
IMSG_CTL_STATUS,
045
2022-02-17
op
IMSG_CTL_NEXT,
046
2022-02-17
op
IMSG_CTL_PREV,
047
2022-02-17
op
IMSG_CTL_JUMP,
048
2022-02-19
op
IMSG_CTL_REPEAT, /* struct player_repeat */
049
2022-02-16
op
050
2022-02-17
op
IMSG_CTL_BEGIN,
051
2022-02-17
op
IMSG_CTL_ADD, /* path to a file */
052
2022-03-02
op
IMSG_CTL_COMMIT, /* offset of the track to jump to */
053
2022-02-17
op
054
2022-02-21
op
IMSG_CTL_MONITOR,
055
2022-02-21
op
056
2022-02-16
op
IMSG_CTL_ERR,
057
2022-02-16
op
};
058
2022-02-16
op
059
2022-02-16
op
struct imsgev {
060
2022-02-16
op
struct imsgbuf ibuf;
061
2022-02-16
op
void (*handler)(int, short, void *);
062
2022-02-16
op
struct event ev;
063
2022-02-16
op
short events;
064
2022-02-16
op
};
065
2022-02-16
op
066
2022-02-16
op
enum actions {
067
2022-02-16
op
NONE,
068
2022-02-16
op
PLAY,
069
2022-02-16
op
PAUSE,
070
2022-02-16
op
TOGGLE,
071
2022-02-16
op
STOP,
072
2022-02-16
op
RESTART,
073
2022-02-16
op
ADD,
074
2022-02-16
op
FLUSH,
075
2022-02-16
op
SHOW,
076
2022-02-16
op
STATUS,
077
2022-02-17
op
PREV,
078
2022-02-17
op
NEXT,
079
2022-02-17
op
LOAD,
080
2022-02-17
op
JUMP,
081
2022-02-19
op
REPEAT,
082
2022-02-21
op
MONITOR,
083
2022-02-16
op
};
084
2022-02-16
op
085
2022-02-16
op
struct ctl_command;
086
2022-02-16
op
087
2022-02-19
op
struct player_repeat {
088
2022-02-19
op
int repeat_one;
089
2022-02-19
op
int repeat_all;
090
2022-02-19
op
};
091
2022-02-19
op
092
2022-02-19
op
struct player_status {
093
2022-02-19
op
char path[PATH_MAX];
094
2022-02-19
op
int status;
095
2022-02-19
op
struct player_repeat rp;
096
2022-02-19
op
};
097
2022-02-19
op
098
2022-02-16
op
struct parse_result {
099
2022-02-16
op
enum actions action;
100
2022-02-16
op
char **files;
101
2022-02-17
op
const char *file;
102
2022-02-17
op
int pretty;
103
2022-02-19
op
struct player_repeat rep;
104
2022-02-16
op
struct ctl_command *ctl;
105
2022-02-16
op
};
106
2022-02-16
op
107
2022-02-16
op
struct ctl_command {
108
2022-02-16
op
const char *name;
109
2022-02-16
op
enum actions action;
110
2022-02-16
op
int (*main)(struct parse_result *, int, char **);
111
2022-02-16
op
const char *usage;
112
2022-02-16
op
int has_pledge;
113
2022-02-16
op
};
114
2022-02-16
op
115
2022-02-17
op
struct playlist;
116
2022-02-17
op
117
2022-02-16
op
/* amused.c */
118
2022-02-16
op
void spawn_daemon(void);
119
2022-02-16
op
void imsg_event_add(struct imsgev *iev);
120
2022-02-16
op
int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
121
2022-02-16
op
pid_t, int, const void *, uint16_t);
122
2022-02-16
op
int main_send_player(uint16_t, int, const void *, uint16_t);
123
2022-02-19
op
int main_play_song(const char *);
124
2022-02-17
op
void main_playlist_jump(struct imsgev *, struct imsg *);
125
2022-02-17
op
void main_playlist_resume(void);
126
2022-02-16
op
void main_playlist_advance(void);
127
2022-02-17
op
void main_playlist_previous(void);
128
2022-02-16
op
void main_restart_track(void);
129
2022-02-17
op
void main_senderr(struct imsgev *, const char *);
130
2022-02-17
op
void main_enqueue(int, struct playlist *, struct imsgev *, struct imsg *);
131
2022-02-16
op
void main_send_playlist(struct imsgev *);
132
2022-02-16
op
void main_send_status(struct imsgev *);
133
2022-02-16
op
134
2022-02-16
op
/* ctl.c */
135
2022-02-16
op
__dead void usage(void);
136
2022-02-16
op
__dead void ctl(int, char **);
137
2022-02-16
op
138
2022-02-16
op
/* player.c */
139
2022-02-21
op
int player_setup(int, int, int);
140
2022-02-16
op
void player_senderr(void);
141
2022-02-16
op
void player_sendeof(void);
142
2022-02-16
op
int player_shouldstop(void);
143
2022-03-09
op
int play(const void *, size_t);
144
2022-02-16
op
int player(int, int);
145
2022-02-16
op
146
2022-02-16
op
void play_oggvorbis(int fd);
147
2022-02-16
op
void play_mp3(int fd);
148
2022-02-16
op
void play_flac(int fd);
149
2022-02-16
op
void play_opus(int fd);
150
2022-02-16
op
151
2022-02-16
op
#endif
Omar Polo