diff options
author | Grigori Goronzy <greg@blackbox> | 2009-06-23 06:31:13 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-06-24 20:49:21 +0200 |
commit | 91d0d3a0824c755608c1c69d6b1192d114a50a96 (patch) | |
tree | 627236b3a571856917980dd58c2d44a89ecf4294 /libao2 | |
parent | c67b681e4c87bc28e39c4897062b2c492d067c34 (diff) |
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.
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/ao_oss.c | 29 |
1 files changed, 29 insertions, 0 deletions
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; |