diff options
author | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-01-24 11:53:52 +0000 |
---|---|---|
committer | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-01-24 11:53:52 +0000 |
commit | a4ac1dc9a422ccc5ed92b519758f68acc3b75e9a (patch) | |
tree | 482b72a25d5f6def662a69c1263f5b3eacbc12f3 | |
parent | 0bd9ce052f695be12d5f329dacdde57c2b59d9ce (diff) |
add option to select mixer channel
patch by Catalin Muresan <catalin.muresan@astral.ro>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11838 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | DOCS/man/en/mplayer.1 | 9 | ||||
-rw-r--r-- | cfg-mplayer.h | 1 | ||||
-rw-r--r-- | libao2/ao_oss.c | 39 | ||||
-rw-r--r-- | mixer.c | 1 | ||||
-rw-r--r-- | mixer.h | 1 |
5 files changed, 48 insertions, 3 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 86d3e72c1a..767443e574 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -1512,6 +1512,15 @@ Signed 32-bit (Big-Endian) .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. diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 2d65a3e98c..76b60bcdbb 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -188,6 +188,7 @@ m_option_t mplayer_opts[]={ {"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}, diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c index 4cd98d9d5e..3591a41adb 100644 --- a/libao2/ao_oss.c +++ b/libao2/ao_oss.c @@ -37,6 +37,7 @@ static audio_buf_info zz; 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 @@ static int control(int cmd,void *arg){ 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 @@ static int control(int cmd,void *arg){ // 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 @@ static int init(int rate,int channels,int format,int flags){ 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); @@ -14,6 +14,7 @@ extern ao_functions_t *audio_out; char * mixer_device=NULL; +char * mixer_channel=NULL; int muted = 0; float mute_l = 0.0f; @@ -3,6 +3,7 @@ #define __MPLAYER_MIXER extern char * mixer_device; +extern char * mixer_channel; extern int muted; extern void mixer_getvolume( float *l,float *r ); |