# HG changeset patch # User al3x # Date 993164835 0 # Node ID f9a46e7843eed1fb103f4ee1db7e18b85ae03141 # Parent 98f732a23cb470a44d01f1cbee45137837a38721 ao_subdevice support diff -r 98f732a23cb4 -r f9a46e7843ee libao2/ao_oss.c --- a/libao2/ao_oss.c Thu Jun 21 23:03:03 2001 +0000 +++ b/libao2/ao_oss.c Thu Jun 21 23:07:15 2001 +0000 @@ -15,6 +15,8 @@ #include "audio_out_internal.h" //#include "afmt.h" +extern int verbose; + static ao_info_t info = { "OSS/ioctl audio output", @@ -37,6 +39,9 @@ static audio_buf_info zz; static int audio_fd=-1; +char *oss_mixer_device = "/dev/mixer"; +int oss_mixer_usemaster = 0; + // to set/get/query special features/parameters static int control(int cmd,int arg){ switch(cmd){ @@ -45,6 +50,50 @@ return CONTROL_OK; case AOCONTROL_QUERY_FORMAT: return CONTROL_TRUE; + case AOCONTROL_GET_VOLUME: + case AOCONTROL_SET_VOLUME: + { + ao_control_vol_t *vol = (ao_control_vol_t *)arg; + int fd, v, mcmd, devs; + + if ((fd = open("/dev/mixer", O_RDONLY)) > 0) + { + ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); + if ((devs & SOUND_MASK_PCM) && (oss_mixer_usemaster == 0)) + if (cmd == AOCONTROL_GET_VOLUME) + mcmd = SOUND_MIXER_READ_PCM; + else + mcmd = SOUND_MIXER_WRITE_PCM; + else if ((devs & SOUND_MASK_VOLUME) && (oss_mixer_usemaster == 1)) + if (cmd == AOCONTROL_GET_VOLUME) + mcmd = SOUND_MIXER_READ_VOLUME; + else + mcmd = SOUND_MIXER_WRITE_VOLUME; + else + { + close(fd); + return CONTROL_ERROR; + } + + if (cmd == AOCONTROL_GET_VOLUME) + { + ioctl(fd, cmd, &v); + vol->right = (v & 0xFF00) >> 8; + vol->left = v & 0x00FF; + } + else + { + v = ((int)vol->right << 8) | (int)vol->left; + ioctl(fd, cmd, &v); + } + close(fd); + return CONTROL_OK; + } + else + return CONTROL_ERROR; + } + return CONTROL_ERROR; + default: } return CONTROL_UNKNOWN; } @@ -56,6 +105,12 @@ printf("ao2: %d Hz %d chans %s\n",rate,channels, audio_out_format_name(format)); + if (ao_subdevice) + dsp = ao_subdevice; + + if (verbose) + printf("audio_setup: using '%s' dsp device\n", dsp); + audio_fd=open(dsp, O_WRONLY); if(audio_fd<0){ printf("Can't open audio device %s -> nosound\n",dsp);