Blame
Date:
Fri Jun 10 07:30:11 2022 UTC
Message:
s/player_setrate/player_setup when the function was renamed, the error messages weren't.
01
2022-02-16
op
/*
02
2022-02-16
op
* Copyright (c) 2022 Omar Polo <op@openbsd.org>
03
2022-02-16
op
*
04
2022-02-16
op
* Permission to use, copy, modify, and distribute this software for any
05
2022-02-16
op
* purpose with or without fee is hereby granted, provided that the above
06
2022-02-16
op
* copyright notice and this permission notice appear in all copies.
07
2022-02-16
op
*
08
2022-02-16
op
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
09
2022-02-16
op
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
2022-02-16
op
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
2022-02-16
op
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
2022-02-16
op
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
2022-02-16
op
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
2022-02-16
op
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
2022-02-16
op
*/
16
2022-02-16
op
17
2022-02-16
op
#include <sys/types.h>
18
2022-02-16
op
#include <sys/queue.h>
19
2022-02-16
op
#include <sys/uio.h>
20
2022-02-16
op
21
2022-02-16
op
#include <err.h>
22
2022-02-16
op
#include <event.h>
23
2022-02-16
op
#include <fcntl.h>
24
2022-02-16
op
#include <math.h>
25
2022-02-16
op
#include <inttypes.h>
26
2022-02-16
op
#include <limits.h>
27
2022-02-16
op
#include <stdio.h>
28
2022-02-16
op
#include <stdint.h>
29
2022-02-16
op
#include <imsg.h>
30
2022-02-16
op
#include <unistd.h>
31
2022-02-16
op
32
2022-02-16
op
#include <vorbis/codec.h>
33
2022-02-16
op
#include <vorbis/vorbisfile.h>
34
2022-02-16
op
35
2022-02-16
op
#include "amused.h"
36
2022-02-18
op
#include "log.h"
37
2022-02-16
op
38
2022-02-16
op
#ifndef nitems
39
2022-02-16
op
#define nitems(x) (sizeof(x)/sizeof(x[0]))
40
2022-02-16
op
#endif
41
2022-02-16
op
42
2022-03-09
op
int
43
2022-02-16
op
play_oggvorbis(int fd)
44
2022-02-16
op
{
45
2022-02-16
op
static uint8_t pcmout[4096];
46
2022-02-16
op
FILE *f;
47
2022-02-16
op
OggVorbis_File vf;
48
2022-02-18
op
vorbis_info *vi;
49
2022-03-09
op
int current_section, eof = 0, ret = 0;
50
2022-02-16
op
51
2022-02-16
op
if ((f = fdopen(fd, "r")) == NULL)
52
2022-02-16
op
err(1, "fdopen");
53
2022-02-16
op
54
2022-02-18
op
if (ov_open_callbacks(f, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
55
2022-02-18
op
log_warnx("input is not an Ogg bitstream");
56
2022-03-09
op
ret = -1;
57
2022-02-18
op
goto end;
58
2022-02-18
op
}
59
2022-02-16
op
60
2022-02-18
op
/*
61
2022-02-18
op
* we could extract some tags by looping over the NULL
62
2022-02-18
op
* terminated array returned by ov_comment(&vf, -1), see
63
2022-02-18
op
* previous revision of this file.
64
2022-02-18
op
*/
65
2022-02-18
op
vi = ov_info(&vf, -1);
66
2022-02-21
op
if (player_setup(16, vi->rate, vi->channels) == -1)
67
2022-06-10
op
err(1, "player_setup");
68
2022-02-16
op
69
2022-02-16
op
while (!eof) {
70
2022-03-23
op
long r;
71
2022-02-16
op
72
2022-03-23
op
r = ov_read(&vf, pcmout, sizeof(pcmout), 0, 2, 1,
73
2022-02-16
op
&current_section);
74
2022-03-23
op
if (r == 0)
75
2022-02-16
op
eof = 1;
76
2022-03-23
op
else if (r > 0) {
77
2022-02-16
op
/* TODO: deal with sample rate changes */
78
2022-03-23
op
if (!play(pcmout, r)) {
79
2022-03-09
op
ret = 1;
80
2022-03-09
op
break;
81
2022-03-09
op
}
82
2022-02-16
op
}
83
2022-02-16
op
}
84
2022-02-16
op
85
2022-02-16
op
ov_clear(&vf);
86
2022-02-18
op
87
2022-02-18
op
end:
88
2022-02-18
op
fclose(f);
89
2022-03-09
op
return ret;
90
2022-02-16
op
}
Omar Polo