summaryrefslogtreecommitdiffstats
path: root/mixer.c
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 /mixer.c
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
Diffstat (limited to 'mixer.c')
-rw-r--r--mixer.c158
1 files changed, 20 insertions, 138 deletions
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;
}
+
+
+
+
+