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.
This commit is contained in:
Grigori Goronzy 2009-06-23 06:31:13 +02:00
parent c67b681e4c
commit 91d0d3a082
2 changed files with 38 additions and 0 deletions

9
configure vendored
View File

@ -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"

View File

@ -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;