summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-02-21 16:02:26 +0000
committeranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-02-21 16:02:26 +0000
commitee2ed8567e3401469fcf13eb96e42d79c4b32714 (patch)
tree90bb902bb5f99813bba6b2bd07ff6620a0d39e0a
parentea1d75800931055c8a04cf76e8b6c914c2ed3e23 (diff)
downloadmpv-ee2ed8567e3401469fcf13eb96e42d79c4b32714.tar.bz2
mpv-ee2ed8567e3401469fcf13eb96e42d79c4b32714.tar.xz
Moved HW dependent mixer stuff to libao and removed master switch
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4789 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--cfg-mplayer.h2
-rw-r--r--libao2/ao_mpegpes.c34
-rw-r--r--libao2/ao_oss.c39
-rw-r--r--libao2/ao_sun.c36
-rw-r--r--libao2/audio_out.c8
-rw-r--r--mixer.c158
-rw-r--r--mixer.h3
-rw-r--r--mplayer.c6
8 files changed, 114 insertions, 172 deletions
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index e479c4b7e6..0c9d686edb 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -141,7 +141,7 @@ static config_t mplayer_opts[]={
// {"dsp", &dsp, CONF_TYPE_STRING, CONF_NOCFG, 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},
- {"master", &mixer_usemaster, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+ {"master", "Option -master was obsolete and has been removed\n" , CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{"channels", &audio_output_channels, CONF_TYPE_INT, CONF_RANGE, 2, 6, NULL},
#ifdef HAVE_X11
{"display", &mDisplayName, CONF_TYPE_STRING, 0, 0, 0, NULL},
diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c
index 891a398b52..1ddf1dd042 100644
--- a/libao2/ao_mpegpes.c
+++ b/libao2/ao_mpegpes.c
@@ -1,11 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include <sys/ioctl.h>
#include "audio_out.h"
#include "audio_out_internal.h"
#include "afmt.h"
+audioMixer_t dvb_mixer={255,255};
+extern int vo_mpegpes_fd;
+extern int vo_mpegpes_fd2;
+
static ao_info_t info =
{
"mpeg-pes audio output",
@@ -19,7 +24,34 @@ LIBAO_EXTERN(mpegpes)
// to set/get/query special features/parameters
static int control(int cmd,int arg){
- return -1;
+ switch(cmd){
+ case AOCONTROL_GET_VOLUME:
+ {
+ if(vo_mpegpes_fd2>=0){
+ ((ao_control_vol_t*)(arg))->left=dvb_mixer.volume_left/2.56;
+ ((ao_control_vol_t*)(arg))->right=dvb_mixer.volume_right/2.56;
+ return CONTROL_OK;
+ }
+ return CONTROL_ERROR;
+ }
+ case AOCONTROL_SET_VOLUME:
+ {
+ if(vo_mpegpes_fd2>=0){
+ dvb_mixer.volume_left=((ao_control_vol_t)(arg)).left*2.56;
+ dvb_mixer.volume_right=((ao_control_vol_t)(arg)).right*2.56;
+ if(dvb_mixer.volume_left>255) dvb_mixer.volume_left=255;
+ if(dvb_mixer.volume_right>255) dvb_mixer.volume_right=255;
+ // printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right);
+ if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MIXER, &dvb_mixer) < 0)){
+ perror("DVB AUDIO SET MIXER: ");
+ return CONTROL_ERROR;
+ }
+ return CONTROL_OK;
+ }
+ return CONTROL_ERROR;
+ }
+ }
+ return CONTROL_UNKNOWN;
}
static int freq=0;
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index 1bcec7f676..b14e8098db 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -10,6 +10,7 @@
//#include <sys/soundcard.h>
#include "../config.h"
+#include "../mixer.h"
#include "afmt.h"
@@ -35,7 +36,6 @@ 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){
@@ -54,36 +54,28 @@ static int control(int cmd,int arg){
if(ao_data.format == AFMT_AC3)
return CONTROL_TRUE;
- if ((fd = open("/dev/mixer", O_RDONLY)) > 0)
+ if ((fd = open(oss_mixer_device, 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 (devs & SOUND_MASK_PCM)
+ {
if (cmd == AOCONTROL_GET_VOLUME)
- mcmd = SOUND_MIXER_READ_VOLUME;
+ {
+ ioctl(fd, SOUND_MIXER_READ_PCM, &v);
+ vol->right = (v & 0xFF00) >> 8;
+ vol->left = v & 0x00FF;
+ }
else
- mcmd = SOUND_MIXER_WRITE_VOLUME;
+ {
+ v = ((int)vol->right << 8) | (int)vol->left;
+ ioctl(fd, SOUND_MIXER_WRITE_PCM, &v);
+ }
+ }
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;
}
@@ -103,6 +95,9 @@ static int init(int rate,int channels,int format,int flags){
if (ao_subdevice)
dsp = ao_subdevice;
+ if(mixer_device)
+ oss_mixer_device=mixer_device;
+
if (verbose)
printf("audio_setup: using '%s' dsp device\n", dsp);
diff --git a/libao2/ao_sun.c b/libao2/ao_sun.c
index 8de1e6bdf0..874a0db6d6 100644
--- a/libao2/ao_sun.c
+++ b/libao2/ao_sun.c
@@ -15,6 +15,7 @@
#endif
#include "../config.h"
+#include "../mixer.h"
#include "audio_out.h"
#include "audio_out_internal.h"
@@ -42,6 +43,7 @@ LIBAO_EXTERN(sun)
#endif
+static char *sun_mixer_device="/dev/audioctl";
static char *audio_dev = NULL;
static int queued_bursts = 0;
static int queued_samples = 0;
@@ -214,6 +216,37 @@ static int control(int cmd,int arg){
return CONTROL_OK;
case AOCONTROL_QUERY_FORMAT:
return CONTROL_TRUE;
+ case AOCONTROL_GET_VOLUME:
+ {
+ int fd,v,cmd,devs;
+
+ fd=open( sun_mixer_device,O_RDONLY );
+ if ( fd != -1 )
+ {
+ struct audio_info info;
+ ioctl( fd,AUDIO_GETINFO,&info);
+ ((ao_control_vol_t*)(arg))->left=info.play.gain * 100. / AUDIO_MAX_GAIN;
+ ((ao_control_vol_t*)(arg))->=info.play.gain * 100. / AUDIO_MAX_GAIN;
+ close( fd );
+ return CONTROL_OK;
+ }
+ return CONTROL_ERROR;
+ }
+ case AOCONTROL_SET_VOLUME:
+ {
+ int fd,v,cmd,devs;
+
+ fd=open( sun_mixer_device,O_RDONLY );
+ if ( fd != -1 )
+ {
+ struct audio_info info;
+ AUDIO_INITINFO(&info);
+ info.play.gain = (r+l) * AUDIO_MAX_GAIN / 100 / 2;
+ ioctl( fd,AUDIO_SETINFO,&info );
+ close( fd );
+ return CONTROL_OK;
+ }
+ return CONTROL_ERROR;
}
return CONTROL_UNKNOWN;
}
@@ -225,6 +258,9 @@ static int init(int rate,int channels,int format,int flags){
audio_info_t info;
int ok;
+ if(mixer_device)
+ sun_mixer_device=mixer_device;
+
if (audio_dev == NULL) {
if ((audio_dev = getenv("AUDIODEV")) == NULL)
audio_dev = "/dev/audio";
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index 927d133a17..e08bed4b77 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -34,8 +34,10 @@ extern ao_functions_t audio_out_sun;
#ifdef USE_SGI_AUDIO
extern ao_functions_t audio_out_sgi;
#endif
-extern ao_functions_t audio_out_pcm;
+#ifdef HAVE_DVB
extern ao_functions_t audio_out_mpegpes;
+#endif
+extern ao_functions_t audio_out_pcm;
extern ao_functions_t audio_out_pss;
extern ao_functions_t audio_out_plugin;
@@ -66,8 +68,10 @@ ao_functions_t* audio_out_drivers[] =
#ifdef HAVE_SDL
&audio_out_sdl,
#endif
- &audio_out_pcm,
+#ifdef HAVE_DVB
&audio_out_mpegpes,
+#endif
+ &audio_out_pcm,
&audio_out_plugin,
// &audio_out_pss,
NULL
diff --git a/mixer.c b/mixer.c
index ff589a12b7..1d723f65c6 100644
--- a/mixer.c
+++ b/mixer.c
@@ -7,157 +7,34 @@
#include "config.h"
#include "mixer.h"
+#include "libao2/audio_out.h"
-#ifdef HAVE_DVB
-#include <ost/audio.h>
-audioMixer_t dvb_mixer={255,255};
-extern int vo_mpegpes_fd;
-extern int vo_mpegpes_fd2;
-#endif
+extern ao_functions_t *audio_out;
-#if defined(USE_OSS_AUDIO)
-
-/*
- * Mixer interface using OSS style soundcard commands.
- */
-
-#include <sys/soundcard.h>
-
-
-char * mixer_device=DEV_MIXER;
-int mixer_usemaster=0;
-
-void mixer_getvolume( float *l,float *r )
-{
- int fd,v,cmd,devs;
-
-#ifdef HAVE_DVB
- if(vo_mpegpes_fd2>=0){
- // DVB card
- *l=dvb_mixer.volume_left/2.56;
- *r=dvb_mixer.volume_right/2.56;
- return;
- }
-#endif
-
- fd=open( mixer_device,O_RDONLY );
- if ( fd != -1 )
- {
- ioctl( fd,SOUND_MIXER_READ_DEVMASK,&devs );
- if ( ( devs & SOUND_MASK_PCM ) && ( mixer_usemaster==0 ) ) cmd=SOUND_MIXER_READ_PCM;
- else
- if ( ( devs & SOUND_MASK_VOLUME ) && ( mixer_usemaster==1 ) ) cmd=SOUND_MIXER_READ_VOLUME;
- else
- {
- close( fd );
- return;
- }
- ioctl( fd,cmd,&v );
- *r=( v & 0xFF00 ) >> 8;
- *l=( v & 0x00FF );
- close( fd );
- }
-}
-
-void mixer_setvolume( float l,float r )
-{
- int fd,v,cmd,devs;
-
-#ifdef HAVE_DVB
- if(vo_mpegpes_fd2>=0){
- // DVB card
- dvb_mixer.volume_left=l*2.56;
- dvb_mixer.volume_right=r*2.56;
- if(dvb_mixer.volume_left>255) dvb_mixer.volume_left=255;
- if(dvb_mixer.volume_right>255) dvb_mixer.volume_right=255;
-// printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right);
- if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MIXER, &dvb_mixer) < 0)){
- perror("DVB AUDIO SET MIXER: ");
- return -1;
- }
- return;
- }
-#endif
-
- fd=open( mixer_device,O_RDONLY );
- if ( fd != -1 )
- {
- ioctl( fd,SOUND_MIXER_READ_DEVMASK,&devs );
- if ( ( devs & SOUND_MASK_PCM ) && ( mixer_usemaster==0 ) ) cmd=SOUND_MIXER_WRITE_PCM;
- else
- if ( ( devs & SOUND_MASK_VOLUME ) && ( mixer_usemaster==1 ) ) cmd=SOUND_MIXER_WRITE_VOLUME;
- else
- {
- close( fd );
- return;
- }
- v=( (int)r << 8 ) | (int)l;
- ioctl( fd,cmd,&v );
- close( fd );
- }
-}
-
-#elif defined(USE_SUN_AUDIO)
-
-/*
- * Mixer interface using Sun style soundcard commands.
- */
-
-#include <sys/audioio.h>
-
-
-char * mixer_device="/dev/audioctl";
-int mixer_usemaster=0;
+char * mixer_device=NULL;
void mixer_getvolume( float *l,float *r )
{
- int fd,v,cmd,devs;
-
- fd=open( mixer_device,O_RDONLY );
- if ( fd != -1 )
- {
- struct audio_info info;
-
- ioctl( fd,AUDIO_GETINFO,&info);
- *r=info.play.gain * 100. / AUDIO_MAX_GAIN;
- *l=info.play.gain * 100. / AUDIO_MAX_GAIN;
- close( fd );
+ ao_control_vol_t vol;
+ *l=0; *r=0;
+ if(audio_out){
+ if(CONTROL_OK != audio_out->control(AOCONTROL_GET_VOLUME,(int)&vol))
+ return;
+ *r=vol.right;
+ *l=vol.left;
}
}
void mixer_setvolume( float l,float r )
{
- int fd,v,cmd,devs;
-
- fd=open( mixer_device,O_RDONLY );
- if ( fd != -1 )
- {
- struct audio_info info;
- AUDIO_INITINFO(&info);
- info.play.gain = (r+l) * AUDIO_MAX_GAIN / 100 / 2;
- ioctl( fd,AUDIO_SETINFO,&info );
- close( fd );
+ ao_control_vol_t vol;
+ vol.right=r; vol.left=l;
+ if(audio_out){
+ if(CONTROL_OK != audio_out->control(AOCONTROL_SET_VOLUME,(int)&vol))
+ return;
}
}
-#else
-
-/*
- * No usable Mixer interface selected.
- * Just some stub routines.
- */
-
-char * mixer_device=NULL;
-int mixer_usemaster=0;
-
-void mixer_getvolume( float *l,float *r ){
- *l = *r = 50.0;
-}
-void mixer_setvolume( float l,float r ){
-}
-
-#endif
-
#define MIXER_CHANGE 3
void mixer_incvolume( void )
@@ -188,3 +65,8 @@ float mixer_getbothvolume( void )
mixer_getvolume( &mixer_l,&mixer_r );
return ( mixer_l + mixer_r ) / 2;
}
+
+
+
+
+
diff --git a/mixer.h b/mixer.h
index cca00469a7..92a59ffc92 100644
--- a/mixer.h
+++ b/mixer.h
@@ -2,9 +2,6 @@
#ifndef __MPLAYER_MIXER
#define __MPLAYER_MIXER
-#define DEV_MIXER "/dev/mixer"
-
-extern int mixer_usemaster;
extern char * mixer_device;
extern void mixer_getvolume( float *l,float *r );
diff --git a/mplayer.c b/mplayer.c
index 23ebbc7831..933fb76600 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -171,7 +171,7 @@ static vo2_handle_t *video_out=NULL;
#else
static vo_functions_t *video_out=NULL;
#endif
-static ao_functions_t *audio_out=NULL;
+ao_functions_t *audio_out=NULL;
// benchmark:
double video_time_usage=0;
@@ -2193,9 +2193,6 @@ if(step_sec>0) {
#endif
}
break;
- case 'm':
- mixer_usemaster=!mixer_usemaster;
- break;
#if 0 // change to 1 for absolute seeking tests
case '1':
@@ -2451,7 +2448,6 @@ if(step_sec>0) {
#endif
} break;
case MP_CMD_MIXER_USEMASTER : {
- mixer_usemaster=!mixer_usemaster;
} break;
case MP_CMD_CONTRAST : {
int v = cmd->args[0].v.i, abs = cmd->args[1].v.i;