Blame


1 3baa2617 2022-02-16 op /*
2 3baa2617 2022-02-16 op * Copyright (c) 2022 Omar Polo <op@openbsd.org>
3 3baa2617 2022-02-16 op *
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.
7 3baa2617 2022-02-16 op *
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.
15 3baa2617 2022-02-16 op */
16 3baa2617 2022-02-16 op
17 f36fd90a 2022-07-09 op #include "config.h"
18 3baa2617 2022-02-16 op
19 3baa2617 2022-02-16 op #include <limits.h>
20 3baa2617 2022-02-16 op
21 3baa2617 2022-02-16 op #include <assert.h>
22 3baa2617 2022-02-16 op #include <errno.h>
23 3baa2617 2022-02-16 op #include <poll.h>
24 3baa2617 2022-02-16 op #include <signal.h>
25 3baa2617 2022-02-16 op #include <sndio.h>
26 14be015f 2022-02-17 op #include <stdio.h>
27 3baa2617 2022-02-16 op #include <stdlib.h>
28 3baa2617 2022-02-16 op #include <stdint.h>
29 3baa2617 2022-02-16 op #include <string.h>
30 3baa2617 2022-02-16 op #include <syslog.h>
31 3baa2617 2022-02-16 op #include <unistd.h>
32 3baa2617 2022-02-16 op
33 3baa2617 2022-02-16 op #include "amused.h"
34 3baa2617 2022-02-16 op #include "log.h"
35 3baa2617 2022-02-16 op #include "xmalloc.h"
36 3baa2617 2022-02-16 op
37 5a4b3030 2022-03-09 op struct sio_hdl *hdl;
38 ff06024f 2022-07-08 op struct sio_par par;
39 c0180200 2022-06-10 op struct pollfd *player_pfds;
40 5a4b3030 2022-03-09 op static struct imsgbuf *ibuf;
41 3baa2617 2022-02-16 op
42 c0180200 2022-06-10 op static int stopped = 1;
43 3baa2617 2022-02-16 op static int nextfd = -1;
44 ff06024f 2022-07-08 op static int64_t samples;
45 60a09ce7 2022-07-09 op static int64_t duration;
46 3baa2617 2022-02-16 op
47 3baa2617 2022-02-16 op volatile sig_atomic_t halted;
48 3baa2617 2022-02-16 op
49 ae335651 2022-07-08 op static void
50 3baa2617 2022-02-16 op player_signal_handler(int signo)
51 3baa2617 2022-02-16 op {
52 3baa2617 2022-02-16 op halted = 1;
53 3baa2617 2022-02-16 op }
54 3baa2617 2022-02-16 op
55 3baa2617 2022-02-16 op int
56 b9d2a697 2022-07-08 op player_setup(unsigned int bits, unsigned int rate, unsigned int channels)
57 3baa2617 2022-02-16 op {
58 4d8a06d4 2022-06-10 op int nfds, fpct;
59 3baa2617 2022-02-16 op
60 a728254f 2022-02-23 op log_debug("%s: bits=%d, rate=%d, channels=%d", __func__,
61 a728254f 2022-02-23 op bits, rate, channels);
62 4d8a06d4 2022-06-10 op
63 4d8a06d4 2022-06-10 op fpct = (rate*5)/100;
64 4d8a06d4 2022-06-10 op
65 4d8a06d4 2022-06-10 op /* don't stop if the parameters are the same */
66 4d8a06d4 2022-06-10 op if (bits == par.bits && channels == par.pchan &&
67 f5237736 2022-06-10 op par.rate - fpct <= rate && rate <= par.rate + fpct) {
68 f5237736 2022-06-10 op if (stopped)
69 f5237736 2022-06-10 op goto start;
70 f5237736 2022-06-10 op return 0;
71 f5237736 2022-06-10 op }
72 3baa2617 2022-02-16 op
73 c0180200 2022-06-10 op again:
74 c0180200 2022-06-10 op if (!stopped) {
75 c0180200 2022-06-10 op sio_stop(hdl);
76 c0180200 2022-06-10 op stopped = 1;
77 c0180200 2022-06-10 op }
78 3baa2617 2022-02-16 op
79 3baa2617 2022-02-16 op sio_initpar(&par);
80 e24324f1 2022-02-21 op par.bits = bits;
81 3baa2617 2022-02-16 op par.rate = rate;
82 7fc831ea 2022-02-18 op par.pchan = channels;
83 c0180200 2022-06-10 op if (!sio_setpar(hdl, &par)) {
84 c0180200 2022-06-10 op if (errno == EAGAIN) {
85 463ce879 2022-06-10 op nfds = sio_pollfd(hdl, player_pfds + 1, POLLOUT);
86 c0180200 2022-06-10 op if (poll(player_pfds + 1, nfds, INFTIM) == -1)
87 c0180200 2022-06-10 op fatal("poll");
88 c0180200 2022-06-10 op goto again;
89 c0180200 2022-06-10 op }
90 f002c42a 2022-05-09 op log_warnx("invalid params (bits=%d, rate=%d, channels=%d",
91 f002c42a 2022-05-09 op bits, rate, channels);
92 7fc831ea 2022-02-18 op return -1;
93 7fc831ea 2022-02-18 op }
94 c0180200 2022-06-10 op if (!sio_getpar(hdl, &par)) {
95 c0180200 2022-06-10 op log_warnx("can't get params");
96 c0180200 2022-06-10 op return -1;
97 c0180200 2022-06-10 op }
98 7fc831ea 2022-02-18 op
99 e24324f1 2022-02-21 op if (par.bits != bits || par.pchan != channels) {
100 7fc831ea 2022-02-18 op log_warnx("failed to set params");
101 3baa2617 2022-02-16 op return -1;
102 3baa2617 2022-02-16 op }
103 3baa2617 2022-02-16 op
104 3baa2617 2022-02-16 op /* TODO: check the sample rate? */
105 3baa2617 2022-02-16 op
106 f5237736 2022-06-10 op start:
107 3baa2617 2022-02-16 op if (!sio_start(hdl)) {
108 3baa2617 2022-02-16 op log_warn("sio_start");
109 3baa2617 2022-02-16 op return -1;
110 3baa2617 2022-02-16 op }
111 c0180200 2022-06-10 op stopped = 0;
112 3baa2617 2022-02-16 op return 0;
113 ff06024f 2022-07-08 op }
114 ff06024f 2022-07-08 op
115 ff06024f 2022-07-08 op void
116 60a09ce7 2022-07-09 op player_setduration(int64_t d)
117 ff06024f 2022-07-08 op {
118 ff06024f 2022-07-08 op int64_t seconds;
119 ff06024f 2022-07-08 op
120 60a09ce7 2022-07-09 op duration = d;
121 ff06024f 2022-07-08 op seconds = duration / par.rate;
122 ff06024f 2022-07-08 op imsg_compose(ibuf, IMSG_LEN, 0, 0, -1, &seconds, sizeof(seconds));
123 ff06024f 2022-07-08 op imsg_flush(ibuf);
124 ff06024f 2022-07-08 op }
125 ff06024f 2022-07-08 op
126 ae335651 2022-07-08 op static void
127 ff06024f 2022-07-08 op player_onmove(void *arg, int delta)
128 ff06024f 2022-07-08 op {
129 ff06024f 2022-07-08 op static int64_t reported;
130 ff06024f 2022-07-08 op int64_t sec;
131 ff06024f 2022-07-08 op
132 ff06024f 2022-07-08 op samples += delta;
133 ff06024f 2022-07-08 op if (llabs(samples - reported) >= par.rate) {
134 ff06024f 2022-07-08 op reported = samples;
135 ff06024f 2022-07-08 op sec = samples / par.rate;
136 ff06024f 2022-07-08 op
137 ff06024f 2022-07-08 op imsg_compose(ibuf, IMSG_POS, 0, 0, -1, &sec, sizeof(sec));
138 ff06024f 2022-07-08 op imsg_flush(ibuf);
139 ff06024f 2022-07-08 op }
140 3baa2617 2022-02-16 op }
141 3baa2617 2022-02-16 op
142 791d3db3 2022-07-09 op void
143 791d3db3 2022-07-09 op player_setpos(int64_t pos)
144 791d3db3 2022-07-09 op {
145 791d3db3 2022-07-09 op samples = pos;
146 791d3db3 2022-07-09 op player_onmove(NULL, 0);
147 791d3db3 2022-07-09 op }
148 791d3db3 2022-07-09 op
149 3baa2617 2022-02-16 op /* process only one message */
150 ae335651 2022-07-08 op static int
151 c2f554ff 2022-07-09 op player_dispatch(int64_t *s, int wait)
152 3baa2617 2022-02-16 op {
153 791d3db3 2022-07-09 op struct player_seek seek;
154 fc4a38af 2022-05-19 op struct pollfd pfd;
155 3baa2617 2022-02-16 op struct imsg imsg;
156 3baa2617 2022-02-16 op ssize_t n;
157 3baa2617 2022-02-16 op int ret;
158 3baa2617 2022-02-16 op
159 3baa2617 2022-02-16 op if (halted != 0)
160 3baa2617 2022-02-16 op return IMSG_STOP;
161 fc4a38af 2022-05-19 op
162 926ee836 2022-05-19 op again:
163 3baa2617 2022-02-16 op if ((n = imsg_get(ibuf, &imsg)) == -1)
164 3baa2617 2022-02-16 op fatal("imsg_get");
165 926ee836 2022-05-19 op if (n == 0) {
166 c2f554ff 2022-07-09 op if (!wait)
167 c2f554ff 2022-07-09 op return -1;
168 c2f554ff 2022-07-09 op
169 926ee836 2022-05-19 op pfd.fd = ibuf->fd;
170 926ee836 2022-05-19 op pfd.events = POLLIN;
171 926ee836 2022-05-19 op if (poll(&pfd, 1, INFTIM) == -1)
172 926ee836 2022-05-19 op fatal("poll");
173 926ee836 2022-05-19 op if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
174 926ee836 2022-05-19 op fatal("imsg_read");
175 926ee836 2022-05-19 op if (n == 0)
176 926ee836 2022-05-19 op fatalx("pipe closed");
177 926ee836 2022-05-19 op goto again;
178 926ee836 2022-05-19 op }
179 3baa2617 2022-02-16 op
180 3baa2617 2022-02-16 op ret = imsg.hdr.type;
181 3baa2617 2022-02-16 op switch (imsg.hdr.type) {
182 3baa2617 2022-02-16 op case IMSG_PLAY:
183 6e4f8947 2022-06-09 op if (nextfd != -1)
184 6e4f8947 2022-06-09 op fatalx("track already enqueued");
185 6e4f8947 2022-06-09 op if ((nextfd = imsg.fd) == -1)
186 6e4f8947 2022-06-09 op fatalx("%s: got invalid file descriptor", __func__);
187 6e4f8947 2022-06-09 op log_debug("song enqueued");
188 3baa2617 2022-02-16 op ret = IMSG_STOP;
189 3baa2617 2022-02-16 op break;
190 3baa2617 2022-02-16 op case IMSG_RESUME:
191 3baa2617 2022-02-16 op case IMSG_PAUSE:
192 3baa2617 2022-02-16 op case IMSG_STOP:
193 3baa2617 2022-02-16 op break;
194 791d3db3 2022-07-09 op case IMSG_CTL_SEEK:
195 791d3db3 2022-07-09 op if (s == NULL)
196 791d3db3 2022-07-09 op break;
197 791d3db3 2022-07-09 op if (IMSG_DATA_SIZE(imsg) != sizeof(seek))
198 791d3db3 2022-07-09 op fatalx("wrong size for seek ctl");
199 791d3db3 2022-07-09 op memcpy(&seek, imsg.data, sizeof(seek));
200 60a09ce7 2022-07-09 op if (seek.percent) {
201 60a09ce7 2022-07-09 op *s = (double)seek.offset * (double)duration / 100.0;
202 60a09ce7 2022-07-09 op } else {
203 60a09ce7 2022-07-09 op *s = seek.offset * par.rate;
204 60a09ce7 2022-07-09 op if (seek.relative)
205 60a09ce7 2022-07-09 op *s += samples;
206 60a09ce7 2022-07-09 op }
207 791d3db3 2022-07-09 op if (*s < 0)
208 3aa75c64 2022-07-09 op *s = 0;
209 791d3db3 2022-07-09 op break;
210 3baa2617 2022-02-16 op default:
211 3baa2617 2022-02-16 op fatalx("unknown imsg %d", imsg.hdr.type);
212 3baa2617 2022-02-16 op }
213 3baa2617 2022-02-16 op
214 fd90976c 2022-06-09 op imsg_free(&imsg);
215 3baa2617 2022-02-16 op return ret;
216 3baa2617 2022-02-16 op }
217 3baa2617 2022-02-16 op
218 ae335651 2022-07-08 op static void
219 17ef54d6 2022-06-22 op player_senderr(const char *errstr)
220 3baa2617 2022-02-16 op {
221 17ef54d6 2022-06-22 op size_t len = 0;
222 17ef54d6 2022-06-22 op
223 17ef54d6 2022-06-22 op if (errstr != NULL)
224 17ef54d6 2022-06-22 op len = strlen(errstr) + 1;
225 17ef54d6 2022-06-22 op
226 17ef54d6 2022-06-22 op imsg_compose(ibuf, IMSG_ERR, 0, 0, -1, errstr, len);
227 3baa2617 2022-02-16 op imsg_flush(ibuf);
228 3baa2617 2022-02-16 op }
229 3baa2617 2022-02-16 op
230 ae335651 2022-07-08 op static void
231 3baa2617 2022-02-16 op player_sendeof(void)
232 3baa2617 2022-02-16 op {
233 3baa2617 2022-02-16 op imsg_compose(ibuf, IMSG_EOF, 0, 0, -1, NULL, 0);
234 3baa2617 2022-02-16 op imsg_flush(ibuf);
235 3baa2617 2022-02-16 op }
236 3baa2617 2022-02-16 op
237 ae335651 2022-07-08 op static int
238 17ef54d6 2022-06-22 op player_playnext(const char **errstr)
239 3baa2617 2022-02-16 op {
240 bf19b03e 2022-05-09 op static char buf[512];
241 bf19b03e 2022-05-09 op ssize_t r;
242 3baa2617 2022-02-16 op int fd = nextfd;
243 3baa2617 2022-02-16 op
244 3baa2617 2022-02-16 op assert(nextfd != -1);
245 3baa2617 2022-02-16 op nextfd = -1;
246 3baa2617 2022-02-16 op
247 ff06024f 2022-07-08 op /* reset samples and set position to zero */
248 ff06024f 2022-07-08 op samples = 0;
249 ff06024f 2022-07-08 op imsg_compose(ibuf, IMSG_POS, 0, 0, -1, &samples, sizeof(samples));
250 ff06024f 2022-07-08 op imsg_flush(ibuf);
251 ff06024f 2022-07-08 op
252 bf19b03e 2022-05-09 op r = read(fd, buf, sizeof(buf));
253 bf19b03e 2022-05-09 op
254 bf19b03e 2022-05-09 op /* 8 byte is the larger magic number */
255 bf19b03e 2022-05-09 op if (r < 8) {
256 17ef54d6 2022-06-22 op *errstr = "read failed";
257 bf19b03e 2022-05-09 op goto err;
258 bf19b03e 2022-05-09 op }
259 bf19b03e 2022-05-09 op
260 bf19b03e 2022-05-09 op if (lseek(fd, 0, SEEK_SET) == -1) {
261 17ef54d6 2022-06-22 op *errstr = "lseek failed";
262 bf19b03e 2022-05-09 op goto err;
263 bf19b03e 2022-05-09 op }
264 bf19b03e 2022-05-09 op
265 bf19b03e 2022-05-09 op if (memcmp(buf, "fLaC", 4) == 0)
266 17ef54d6 2022-06-22 op return play_flac(fd, errstr);
267 bf19b03e 2022-05-09 op if (memcmp(buf, "ID3", 3) == 0 ||
268 bf19b03e 2022-05-09 op memcmp(buf, "\xFF\xFB", 2) == 0)
269 17ef54d6 2022-06-22 op return play_mp3(fd, errstr);
270 bf19b03e 2022-05-09 op if (memmem(buf, r, "OpusHead", 8) != NULL)
271 17ef54d6 2022-06-22 op return play_opus(fd, errstr);
272 bf19b03e 2022-05-09 op if (memmem(buf, r, "OggS", 4) != NULL)
273 17ef54d6 2022-06-22 op return play_oggvorbis(fd, errstr);
274 25cb72fb 2022-02-22 op
275 17ef54d6 2022-06-22 op *errstr = "unknown file type";
276 bf19b03e 2022-05-09 op err:
277 184600a8 2022-05-09 op close(fd);
278 06412529 2022-05-09 op return -1;
279 3baa2617 2022-02-16 op }
280 3baa2617 2022-02-16 op
281 ae335651 2022-07-08 op static int
282 791d3db3 2022-07-09 op player_pause(int64_t *s)
283 3baa2617 2022-02-16 op {
284 3baa2617 2022-02-16 op int r;
285 3baa2617 2022-02-16 op
286 c2f554ff 2022-07-09 op r = player_dispatch(s, 1);
287 3ad8bae8 2022-07-09 op return r == IMSG_RESUME || r == IMSG_CTL_SEEK;
288 3baa2617 2022-02-16 op }
289 3baa2617 2022-02-16 op
290 ae335651 2022-07-08 op static int
291 c2f554ff 2022-07-09 op player_shouldstop(int64_t *s, int wait)
292 3baa2617 2022-02-16 op {
293 c2f554ff 2022-07-09 op switch (player_dispatch(s, wait)) {
294 3baa2617 2022-02-16 op case IMSG_PAUSE:
295 791d3db3 2022-07-09 op if (player_pause(s))
296 3baa2617 2022-02-16 op break;
297 3baa2617 2022-02-16 op /* fallthrough */
298 3baa2617 2022-02-16 op case IMSG_STOP:
299 3baa2617 2022-02-16 op return 1;
300 3baa2617 2022-02-16 op }
301 3baa2617 2022-02-16 op
302 3baa2617 2022-02-16 op return 0;
303 3baa2617 2022-02-16 op }
304 3baa2617 2022-02-16 op
305 3baa2617 2022-02-16 op int
306 791d3db3 2022-07-09 op play(const void *buf, size_t len, int64_t *s)
307 2139c525 2022-03-09 op {
308 c0180200 2022-06-10 op size_t w;
309 c2f554ff 2022-07-09 op int nfds, revents, r, wait;
310 c0180200 2022-06-10 op
311 791d3db3 2022-07-09 op *s = -1;
312 c0180200 2022-06-10 op while (len != 0) {
313 c0180200 2022-06-10 op nfds = sio_pollfd(hdl, player_pfds + 1, POLLOUT);
314 c0180200 2022-06-10 op r = poll(player_pfds, nfds + 1, INFTIM);
315 c0180200 2022-06-10 op if (r == -1)
316 c0180200 2022-06-10 op fatal("poll");
317 c0180200 2022-06-10 op
318 c2f554ff 2022-07-09 op wait = player_pfds[0].revents & (POLLHUP|POLLIN);
319 c2f554ff 2022-07-09 op if (player_shouldstop(s, wait)) {
320 c2f554ff 2022-07-09 op sio_flush(hdl);
321 c2f554ff 2022-07-09 op stopped = 1;
322 c2f554ff 2022-07-09 op return 0;
323 c0180200 2022-06-10 op }
324 c0180200 2022-06-10 op
325 c0180200 2022-06-10 op revents = sio_revents(hdl, player_pfds + 1);
326 c0180200 2022-06-10 op if (revents & POLLHUP)
327 c0180200 2022-06-10 op fatalx("sndio hang-up");
328 c0180200 2022-06-10 op if (revents & POLLOUT) {
329 c0180200 2022-06-10 op w = sio_write(hdl, buf, len);
330 c0180200 2022-06-10 op len -= w;
331 c0180200 2022-06-10 op buf += w;
332 c0180200 2022-06-10 op }
333 c0180200 2022-06-10 op }
334 c0180200 2022-06-10 op
335 2139c525 2022-03-09 op return 1;
336 2139c525 2022-03-09 op }
337 2139c525 2022-03-09 op
338 2139c525 2022-03-09 op int
339 3baa2617 2022-02-16 op player(int debug, int verbose)
340 3baa2617 2022-02-16 op {
341 fc4a38af 2022-05-19 op int r;
342 fc4a38af 2022-05-19 op
343 3baa2617 2022-02-16 op log_init(debug, LOG_DAEMON);
344 3baa2617 2022-02-16 op log_setverbose(verbose);
345 3baa2617 2022-02-16 op
346 3baa2617 2022-02-16 op setproctitle("player");
347 3baa2617 2022-02-16 op log_procinit("player");
348 3baa2617 2022-02-16 op
349 3baa2617 2022-02-16 op #if 0
350 3baa2617 2022-02-16 op {
351 3baa2617 2022-02-16 op static int attached;
352 3baa2617 2022-02-16 op
353 3baa2617 2022-02-16 op while (!attached)
354 3baa2617 2022-02-16 op sleep(1);
355 3baa2617 2022-02-16 op }
356 3baa2617 2022-02-16 op #endif
357 3baa2617 2022-02-16 op
358 aecca17c 2022-06-10 op if ((hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1)) == NULL)
359 aecca17c 2022-06-10 op fatal("sio_open");
360 3baa2617 2022-02-16 op
361 ff06024f 2022-07-08 op sio_onmove(hdl, player_onmove, NULL);
362 ff06024f 2022-07-08 op
363 c0180200 2022-06-10 op /* allocate one extra for imsg */
364 c0180200 2022-06-10 op player_pfds = calloc(sio_nfds(hdl) + 1, sizeof(*player_pfds));
365 c0180200 2022-06-10 op if (player_pfds == NULL)
366 c0180200 2022-06-10 op fatal("calloc");
367 c0180200 2022-06-10 op
368 c0180200 2022-06-10 op player_pfds[0].events = POLLIN;
369 c0180200 2022-06-10 op player_pfds[0].fd = 3;
370 c0180200 2022-06-10 op
371 3baa2617 2022-02-16 op ibuf = xmalloc(sizeof(*ibuf));
372 3baa2617 2022-02-16 op imsg_init(ibuf, 3);
373 3baa2617 2022-02-16 op
374 3baa2617 2022-02-16 op signal(SIGINT, player_signal_handler);
375 3baa2617 2022-02-16 op signal(SIGTERM, player_signal_handler);
376 3baa2617 2022-02-16 op
377 3baa2617 2022-02-16 op signal(SIGHUP, SIG_IGN);
378 3baa2617 2022-02-16 op signal(SIGPIPE, SIG_IGN);
379 3baa2617 2022-02-16 op
380 251e00ff 2022-03-10 op if (pledge("stdio recvfd audio", NULL) == -1)
381 3baa2617 2022-02-16 op fatal("pledge");
382 3baa2617 2022-02-16 op
383 3baa2617 2022-02-16 op while (!halted) {
384 17ef54d6 2022-06-22 op const char *errstr = NULL;
385 17ef54d6 2022-06-22 op
386 3baa2617 2022-02-16 op while (nextfd == -1)
387 c2f554ff 2022-07-09 op player_dispatch(NULL, 1);
388 06412529 2022-05-09 op
389 17ef54d6 2022-06-22 op r = player_playnext(&errstr);
390 239029b6 2022-05-09 op if (r == -1)
391 17ef54d6 2022-06-22 op player_senderr(errstr);
392 239029b6 2022-05-09 op if (r == 0)
393 06412529 2022-05-09 op player_sendeof();
394 3baa2617 2022-02-16 op }
395 3baa2617 2022-02-16 op
396 3baa2617 2022-02-16 op return 0;
397 3baa2617 2022-02-16 op }