Mercurial > mplayer.hg
changeset 11837:4e8f8efb6906
add option to select mixer channel
patch by Catalin Muresan <catalin.muresan@astral.ro>
author | attila |
---|---|
date | Sat, 24 Jan 2004 11:53:52 +0000 |
parents | 33351e4ce3de |
children | b4f1df0c1e3a |
files | DOCS/man/en/mplayer.1 cfg-mplayer.h libao2/ao_oss.c mixer.c mixer.h |
diffstat | 5 files changed, 48 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Fri Jan 23 21:34:28 2004 +0000 +++ b/DOCS/man/en/mplayer.1 Sat Jan 24 11:53:52 2004 +0000 @@ -1512,6 +1512,15 @@ .B \-mixer <device> This option will tell MPlayer to use a different device for mixing than /dev/\:mixer. +.TP +.B \-mixer-channel <mixer line> (-ao oss only) +This option will tell MPlayer to use a different channel for controlling +volume than the default PCM. Options include +.B vol, pcm, line. +For a complete list of options look for SOUND_DEVICE_NAMES in +.nh +/usr/include/linux/soundcard.h. +.hy .TP .B \-nowaveheader (\-ao pcm only) Don't include wave header.
--- a/cfg-mplayer.h Fri Jan 23 21:34:28 2004 +0000 +++ b/cfg-mplayer.h Sat Jan 24 11:53:52 2004 +0000 @@ -188,6 +188,7 @@ {"aop", ao_plugin_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, {"dsp", "Use -ao oss:dsp_path!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, {"mixer", &mixer_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"mixer-channel", &mixer_channel, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"master", "Option -master has been removed, use -aop list=volume instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, // override audio buffer size (used only by -ao oss, anyway obsolete...) {"abs", &ao_data.buffersize, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
--- a/libao2/ao_oss.c Fri Jan 23 21:34:28 2004 +0000 +++ b/libao2/ao_oss.c Sat Jan 24 11:53:52 2004 +0000 @@ -37,6 +37,7 @@ static int audio_fd=-1; char *oss_mixer_device = PATH_DEV_MIXER; +int oss_mixer_channel = SOUND_MIXER_PCM; // to set/get/query special features/parameters static int control(int cmd,void *arg){ @@ -61,18 +62,18 @@ if ((fd = open(oss_mixer_device, O_RDONLY)) > 0) { ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); - if (devs & SOUND_MASK_PCM) + if (devs & (1 << oss_mixer_channel)) { if (cmd == AOCONTROL_GET_VOLUME) { - ioctl(fd, SOUND_MIXER_READ_PCM, &v); + ioctl(fd, MIXER_READ(oss_mixer_channel), &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); + ioctl(fd, MIXER_WRITE(oss_mixer_channel), &v); } } else @@ -92,6 +93,7 @@ // open & setup audio device // return: 1=success 0=fail static int init(int rate,int channels,int format,int flags){ + char *mixer_channels [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; mp_msg(MSGT_AO,MSGL_V,"ao2: %d Hz %d chans %s\n",rate,channels, audio_out_format_name(format)); @@ -102,7 +104,38 @@ if(mixer_device) oss_mixer_device=mixer_device; + if(mixer_channel){ + int fd, devs, i; + + if ((fd = open(oss_mixer_device, O_RDONLY)) == -1){ + mp_msg(MSGT_AO,MSGL_ERR,"audio_setup: Can't open mixer device %s: %s\n", + oss_mixer_device, strerror(errno)); + }else{ + ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); + close(fd); + + for (i=0; i<SOUND_MIXER_NRDEVICES; i++){ + if(!strcasecmp(mixer_channels[i], mixer_channel)){ + if(!(devs & (1 << i))){ + mp_msg(MSGT_AO,MSGL_ERR,"audio_setup: Audio card mixer does not have channel '%s' using default\n", + mixer_channel); + i = SOUND_MIXER_NRDEVICES+1; + break; + } + oss_mixer_channel = i; + break; + } + } + if(i==SOUND_MIXER_NRDEVICES){ + mp_msg(MSGT_AO,MSGL_ERR,"audio_setup: Can't find mixer channel '%s' using default\n", + mixer_channel); + } + } + } + mp_msg(MSGT_AO,MSGL_V,"audio_setup: using '%s' dsp device\n", dsp); + mp_msg(MSGT_AO,MSGL_V,"audio_setup: using '%s' mixer device\n", oss_mixer_device); + mp_msg(MSGT_AO,MSGL_V,"audio_setup: using '%s' mixer device\n", mixer_channels[oss_mixer_channel]); #ifdef __linux__ audio_fd=open(dsp, O_WRONLY | O_NONBLOCK);