summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-06-23 06:31:13 +0200
committerGrigori Goronzy <greg@blackbox>2009-06-24 20:49:21 +0200
commit91d0d3a0824c755608c1c69d6b1192d114a50a96 (patch)
tree627236b3a571856917980dd58c2d44a89ecf4294
parentc67b681e4c87bc28e39c4897062b2c492d067c34 (diff)
downloadmpv-91d0d3a0824c755608c1c69d6b1192d114a50a96.tar.bz2
mpv-91d0d3a0824c755608c1c69d6b1192d114a50a96.tar.xz
Add OSS4 vmix volume control to ao_oss
Support for per-application volume control, introduced by OSS4. This adds a check in configure to add the proper include path to the CFLAGS, if needed. The path is taken from /etc/oss.conf.
-rwxr-xr-xconfigure9
-rw-r--r--libao2/ao_oss.c29
2 files changed, 38 insertions, 0 deletions
diff --git a/configure b/configure
index f2c3f2f592..1671c6da71 100755
--- a/configure
+++ b/configure
@@ -5351,6 +5351,15 @@ EOF
cc_check && _real_ossaudio=yes
if test "$_real_ossaudio" = yes; then
def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/dsp"'
+ # Check for OSS4 headers (override default headers)
+ # Does not apply to systems where OSS4 is native (e.g. FreeBSD)
+ if test -f /etc/oss.conf; then
+ . /etc/oss.conf
+ _ossinc="$OSSLIBDIR/include"
+ if test -f "$_ossinc/sys/soundcard.h"; then
+ extra_cflags="-I$_ossinc $extra_cflags"
+ fi
+ fi
elif netbsd || openbsd ; then
def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound"'
extra_ldflags="$extra_ldflags -lossaudio"
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index e4688d1723..3407118f59 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -172,6 +172,29 @@ static int prepause_space;
static const char *oss_mixer_device = PATH_DEV_MIXER;
static int oss_mixer_channel = SOUND_MIXER_PCM;
+#ifdef SNDCTL_DSP_GETPLAYVOL
+static int volume_oss4(ao_control_vol_t *vol, int cmd) {
+ int v;
+
+ if (audio_fd < 0)
+ return CONTROL_ERROR;
+
+ if (cmd == AOCONTROL_GET_VOLUME) {
+ if (ioctl(audio_fd, SNDCTL_DSP_GETPLAYVOL, &v) == -1)
+ return CONTROL_ERROR;
+ vol->right = (v & 0xff00) >> 8;
+ vol->left = v & 0x00ff;
+ return CONTROL_OK;
+ } else if (cmd == AOCONTROL_SET_VOLUME) {
+ v = ((int) vol->right << 8) | (int) vol->left;
+ if (ioctl(audio_fd, SNDCTL_DSP_SETPLAYVOL, &v) == -1)
+ return CONTROL_ERROR;
+ return CONTROL_OK;
+ } else
+ return CONTROL_UNKNOWN;
+}
+#endif
+
// to set/get/query special features/parameters
static int control(int cmd,void *arg){
switch(cmd){
@@ -197,6 +220,12 @@ static int control(int cmd,void *arg){
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
int fd, v, devs;
+#ifdef SNDCTL_DSP_GETPLAYVOL
+ // Try OSS4 first
+ if (volume_oss4(vol, cmd) == CONTROL_OK)
+ return CONTROL_OK;
+#endif
+
if(ao_data.format == AF_FORMAT_AC3)
return CONTROL_TRUE;