--- libao2/ao_arts.c.orig 2003-03-21 17:42:50.000000000 +0100 +++ libao2/ao_arts.c 2004-01-19 19:06:05.000000000 +0100 @@ -10,12 +10,17 @@ #include #include -#include "audio_out.h" -#include "audio_out_internal.h" -#include "afmt.h" +#include +#include + #include "../config.h" #include "../mp_msg.h" +#include "afmt.h" + +#include "audio_out.h" +#include "audio_out_internal.h" + #define OBTAIN_BITRATE(a) (((a != AFMT_U8) && (a != AFMT_S8)) ? 16 : 8) /* Feel free to experiment with the following values: */ @@ -34,9 +39,49 @@ LIBAO_EXTERN(arts) -static int control(int cmd, void *arg) -{ - return(CONTROL_UNKNOWN); +// to set/get/query special features/parameters +static int control(int cmd,void *arg){ + switch(cmd){ + 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, devs; + + if(ao_data.format == AFMT_AC3) + return CONTROL_TRUE; + + if ((fd = open(PATH_DEV_MIXER, O_RDONLY)) > 0) + { + ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); + if (devs & SOUND_MASK_PCM) + { + if (cmd == AOCONTROL_GET_VOLUME) + { + ioctl(fd, SOUND_MIXER_READ_PCM, &v); + vol->right = (v & 0xFF00) >> 8; + vol->left = v & 0x00FF; + } + else + { + v = ((int)vol->right << 8) | (int)vol->left; + ioctl(fd, SOUND_MIXER_WRITE_PCM, &v); + } + } + else + { + close(fd); + return CONTROL_ERROR; + } + close(fd); + return CONTROL_OK; + } + } + return CONTROL_ERROR; + } + return CONTROL_UNKNOWN; } static int init(int rate_hz, int channels, int format, int flags)