[MPlayer-dev-eng] [PATCH] Add -mixer-channel option to specify mixer channel to use for volume control
Catalin Muresan
catalin.muresan at astral.ro
Mon Nov 10 11:13:11 CET 2003
Hello,
I've made a patch to add -mixer-channel <channel> option to mplayer
so i can control the volume while i watch TV with mplayer, but mplayer does
not use audio output for tv interface (i found out _after_ i made the patch
:( ) but here it is (attached, against 1.0pre2) if someone wants it.
--
Catalin Muresan
ASTRAL TELECOM
Internet Department
Technology Engineer
-------------- next part --------------
diff -urN MPlayer-1.0pre2/cfg-mplayer.h MPlayer-1.0pre2-chmix/cfg-mplayer.h
--- MPlayer-1.0pre2/cfg-mplayer.h Fri Oct 3 21:13:15 2003
+++ MPlayer-1.0pre2-chmix/cfg-mplayer.h Mon Nov 10 11:57:45 2003
@@ -185,6 +185,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},
diff -urN MPlayer-1.0pre2/libao2/ao_oss.c MPlayer-1.0pre2-chmix/libao2/ao_oss.c
--- MPlayer-1.0pre2/libao2/ao_oss.c Thu Aug 14 00:04:15 2003
+++ MPlayer-1.0pre2-chmix/libao2/ao_oss.c Mon Nov 10 12:09:44 2003
@@ -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);
diff -urN MPlayer-1.0pre2/mixer.c MPlayer-1.0pre2-chmix/mixer.c
--- MPlayer-1.0pre2/mixer.c Mon Mar 31 20:32:46 2003
+++ MPlayer-1.0pre2-chmix/mixer.c Mon Nov 10 11:57:45 2003
@@ -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;
diff -urN MPlayer-1.0pre2/mixer.h MPlayer-1.0pre2-chmix/mixer.h
--- MPlayer-1.0pre2/mixer.h Thu Jun 6 10:13:42 2002
+++ MPlayer-1.0pre2-chmix/mixer.h Mon Nov 10 11:57:45 2003
@@ -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 );
More information about the MPlayer-dev-eng
mailing list