View | Details | Raw Unified | Return to bug 216571
Collapse All | Expand All

(-)Makefile (+6 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	sndio
4
PORTNAME=	sndio
5
PORTVERSION=	1.2.0
5
PORTVERSION=	1.2.0
6
PORTREVISION=	1
6
CATEGORIES=	audio
7
CATEGORIES=	audio
7
MASTER_SITES=	http://www.sndio.org/
8
MASTER_SITES=	http://www.sndio.org/
8
9
Lines 24-29 Link Here
24
# as is so not worth fixing
25
# as is so not worth fixing
25
MAKE_JOBS_UNSAFE=	yes
26
MAKE_JOBS_UNSAFE=	yes
26
27
28
post-patch:
29
# Make sure sndiod can be started inside jails as root
30
	@${REINPLACE_CMD} 's|err(1, "setpriority")|warn("setpriority")|' \
31
		${WRKSRC}/sndiod/sndiod.c
32
27
post-install:
33
post-install:
28
	@${STRIP_CMD} \
34
	@${STRIP_CMD} \
29
		${STAGEDIR}${PREFIX}/lib/libsndio.so.6.1 \
35
		${STAGEDIR}${PREFIX}/lib/libsndio.so.6.1 \
(-)files/patch-libsndio_sio.c (+11 lines)
Line 0 Link Here
1
--- libsndio/sio.c.orig	2016-11-06 11:21:59 UTC
2
+++ libsndio/sio.c
3
@@ -65,7 +65,7 @@ sio_open(const char *str, unsigned int m
4
 #if defined(USE_SUN)
5
 		return _sio_sun_open("rsnd/0", mode, nbio);
6
 #elif defined(USE_OSS)
7
-		return _sio_oss_open("rsnd/0", mode, nbio);
8
+		return _sio_oss_open(SIO_DEVANY, mode, nbio);
9
 #elif defined(USE_ALSA)
10
 		return _sio_alsa_open("rsnd/0", mode, nbio);
11
 #else
(-)files/patch-libsndio_sio__oss.c (+123 lines)
Line 0 Link Here
1
--- libsndio/sio_oss.c.orig	2016-11-06 11:21:59 UTC
2
+++ libsndio/sio_oss.c
3
@@ -108,6 +108,8 @@ static int sio_oss_xrun(struct sio_oss_h
4
 static size_t sio_oss_read(struct sio_hdl *, void *, size_t);
5
 static size_t sio_oss_write(struct sio_hdl *, const void *, size_t);
6
 static void sio_oss_close(struct sio_hdl *);
7
+static int sio_oss_setvol(struct sio_hdl *, unsigned int);
8
+static void sio_oss_getvol(struct sio_hdl *);
9
 
10
 static struct sio_ops sio_oss_ops = {
11
 	sio_oss_close,
12
@@ -121,8 +123,8 @@ static struct sio_ops sio_oss_ops = {
13
 	sio_oss_nfds,
14
 	sio_oss_pollfd,
15
 	sio_oss_revents,
16
-	NULL, /* setvol */
17
-	NULL, /* getvol */
18
+	sio_oss_setvol,
19
+	sio_oss_getvol,
20
 };
21
 
22
 /*
23
@@ -228,12 +230,10 @@ sio_oss_getcap(struct sio_hdl *sh, struc
24
 }
25
 
26
 static int
27
-sio_oss_getfd(const char *str, unsigned int mode, int nbio)
28
+_sio_oss_getdev(const char *str, char *path, size_t len)
29
 {
30
 	const char *p;
31
-	char path[DEVPATH_MAX];
32
 	unsigned int devnum;
33
-	int fd, flags, val;
34
 
35
 	p = _sndio_parsetype(str, "rsnd");
36
 	if (p == NULL) {
37
@@ -253,7 +253,24 @@ sio_oss_getfd(const char *str, unsigned 
38
 		DPRINTF("sio_oss_getfd: %s: number expected after '/'\n", str);
39
 		return -1;
40
 	}
41
-	snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
42
+	snprintf(path, len, DEVPATH_PREFIX "%u", devnum);
43
+	return 0;
44
+}
45
+
46
+static int
47
+sio_oss_getfd(const char *str, unsigned int mode, int nbio)
48
+{
49
+	char path[DEVPATH_MAX];
50
+	int fd, flags, val;
51
+	audio_buf_info bi;
52
+
53
+	if (strcmp(str, SIO_DEVANY) == 0) {
54
+		/* Use /dev/dsp (the default device) directly */
55
+		snprintf(path, sizeof(path), DEVPATH_PREFIX);
56
+	} else if (_sio_oss_getdev(str, path, sizeof(path)) < 0) {
57
+		return -1;
58
+	}
59
+
60
 	if (mode == (SIO_PLAY | SIO_REC))
61
 		flags = O_RDWR;
62
 	else
63
@@ -264,6 +281,19 @@ sio_oss_getfd(const char *str, unsigned 
64
 		DPERROR(path);
65
 		return -1;
66
 	}
67
+	/*
68
+	 * Check if the device supports playing/recording.
69
+	 * Unfortunately, it's possible for devices to be opened RDWR
70
+	 * even when they don't support playing/recording.
71
+	 */
72
+	if (mode & SIO_PLAY && ioctl(fd, SNDCTL_DSP_GETOSPACE, &bi) < 0) {
73
+		close(fd);
74
+		return -1;
75
+	}
76
+	if (mode & SIO_REC && ioctl(fd, SNDCTL_DSP_GETISPACE, &bi) < 0) {
77
+		close(fd);
78
+		return -1;
79
+	}
80
 	val = 1;
81
 	if (ioctl(fd, SNDCTL_DSP_LOW_WATER, &val) < 0) {
82
 		DPERROR("sio_oss_start: LOW_WATER");
83
@@ -736,4 +766,40 @@ sio_oss_revents(struct sio_hdl *sh, stru
84
 	return revents;
85
 }
86
 
87
+static int
88
+sio_oss_setvol(struct sio_hdl *sh, unsigned int vol)
89
+{
90
+	struct sio_oss_hdl *hdl = (struct sio_oss_hdl *)sh;
91
+	int newvol;
92
+
93
+	/* Scale to 0..100 */
94
+	newvol = 1.0 * 100 * vol / SIO_MAXVOL;
95
+	newvol = newvol | (newvol << 8);
96
+
97
+	if (ioctl(hdl->fd, SNDCTL_DSP_SETPLAYVOL, &newvol) < 0) {
98
+		DPERROR("sio_oss_setvol");
99
+		hdl->sio.eof = 1;
100
+		return 0;
101
+	}
102
+
103
+	return 1;
104
+}
105
+
106
+static void
107
+sio_oss_getvol(struct sio_hdl *sh)
108
+{
109
+	struct sio_oss_hdl *hdl = (struct sio_oss_hdl *)sh;
110
+	int vol;
111
+
112
+	if (ioctl(hdl->fd, SNDCTL_DSP_GETPLAYVOL, &vol) < 0) {
113
+		DPERROR("sio_oss_getvol");
114
+		hdl->sio.eof = 1;
115
+		return;
116
+	}
117
+
118
+	/* Use left channel volume and scale to SIO_MAXVOL */
119
+	vol = SIO_MAXVOL * 1.0 * (vol & 0x7f) / 100;
120
+	_sio_onvol_cb(&hdl->sio, vol);
121
+}
122
+
123
 #endif /* defined USE_OSS */
(-)pkg-message (-27 lines)
Lines 1-27 Link Here
1
Enable the sndiod server with:
2
3
    sysrc sndiod_enable=YES
4
    service sndiod start
5
6
Please note that by default sndiod is configured with a monitoring
7
sub-device i.e. a device through which you can record everything that
8
plays through sndiod:
9
10
    aucat -f snd/0.monitor -o recording.wav
11
12
Make sure you override sndiod_flags if this is not wanted.
13
14
By default the rc.d script passes '-c 0:7 -j off' to sndiod, so that
15
it uses all 8 virtual channels provided by OSS.  If you override
16
sndiod_flags consider keeping these options, so that multi-channel
17
audio works as you'd expect.
18
19
There is little sndio support in the FreeBSD ports tree right now.  If
20
your favourite port is missing support please take a look at the fork
21
at https://github.com/t6/freebsd-ports-sndio and
22
https://github.com/t6/freebsd-ports-sndio/wiki/Status which contains
23
patches that enable sndio support in various ports.
24
25
audio/pulseaudio-module-sndio is a PulseAudio module that allows you
26
to play to your sndio server.  This is useful for ports that have
27
PulseAudio support but no direct sndio support.

Return to bug 216571