Mercurial > mplayer.hg
changeset 4788:d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
author | anders |
---|---|
date | Thu, 21 Feb 2002 16:02:26 +0000 |
parents | 1ee5574d67d6 |
children | c2bb05709676 |
files | cfg-mplayer.h libao2/ao_mpegpes.c libao2/ao_oss.c libao2/ao_sun.c libao2/audio_out.c mixer.c mixer.h mplayer.c |
diffstat | 8 files changed, 114 insertions(+), 172 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-mplayer.h Thu Feb 21 15:44:51 2002 +0000 +++ b/cfg-mplayer.h Thu Feb 21 16:02:26 2002 +0000 @@ -141,7 +141,7 @@ // {"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},
--- a/libao2/ao_mpegpes.c Thu Feb 21 15:44:51 2002 +0000 +++ b/libao2/ao_mpegpes.c Thu Feb 21 16:02:26 2002 +0000 @@ -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 @@ // 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;
--- a/libao2/ao_oss.c Thu Feb 21 15:44:51 2002 +0000 +++ b/libao2/ao_oss.c Thu Feb 21 16:02:26 2002 +0000 @@ -10,6 +10,7 @@ //#include <sys/soundcard.h> #include "../config.h" +#include "../mixer.h" #include "afmt.h" @@ -35,7 +36,6 @@ 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 @@ 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 (devs & SOUND_MASK_PCM) + { if (cmd == AOCONTROL_GET_VOLUME) - mcmd = SOUND_MIXER_READ_PCM; + { + ioctl(fd, SOUND_MIXER_READ_PCM, &v); + vol->right = (v & 0xFF00) >> 8; + vol->left = v & 0x00FF; + } else - mcmd = SOUND_MIXER_WRITE_PCM; - else if ((devs & SOUND_MASK_VOLUME) && (oss_mixer_usemaster == 1)) - if (cmd == AOCONTROL_GET_VOLUME) - mcmd = SOUND_MIXER_READ_VOLUME; - 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 @@ 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);
--- a/libao2/ao_sun.c Thu Feb 21 15:44:51 2002 +0000 +++ b/libao2/ao_sun.c Thu Feb 21 16:02:26 2002 +0000 @@ -15,6 +15,7 @@ #endif #include "../config.h" +#include "../mixer.h" #include "audio_out.h" #include "audio_out_internal.h" @@ -42,6 +43,7 @@ #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 @@ 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 @@ 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";
--- a/libao2/audio_out.c Thu Feb 21 15:44:51 2002 +0000 +++ b/libao2/audio_out.c Thu Feb 21 16:02:26 2002 +0000 @@ -34,8 +34,10 @@ #ifdef USE_SGI_AUDIO extern ao_functions_t audio_out_sgi; #endif +#ifdef HAVE_DVB +extern ao_functions_t audio_out_mpegpes; +#endif extern ao_functions_t audio_out_pcm; -extern ao_functions_t audio_out_mpegpes; extern ao_functions_t audio_out_pss; extern ao_functions_t audio_out_plugin; @@ -66,8 +68,10 @@ #ifdef HAVE_SDL &audio_out_sdl, #endif +#ifdef HAVE_DVB + &audio_out_mpegpes, +#endif &audio_out_pcm, - &audio_out_mpegpes, &audio_out_plugin, // &audio_out_pss, NULL
--- a/mixer.c Thu Feb 21 15:44:51 2002 +0000 +++ b/mixer.c Thu Feb 21 16:02:26 2002 +0000 @@ -7,157 +7,34 @@ #include "config.h" #include "mixer.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 - -#if defined(USE_OSS_AUDIO) +#include "libao2/audio_out.h" -/* - * Mixer interface using OSS style soundcard commands. - */ +extern ao_functions_t *audio_out; -#include <sys/soundcard.h> - - -char * mixer_device=DEV_MIXER; -int mixer_usemaster=0; +char * mixer_device=NULL; 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 ); + 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; - -#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 ); + 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; } } -#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; - -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 ); - } -} - -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 ); - } -} - -#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 @@ mixer_getvolume( &mixer_l,&mixer_r ); return ( mixer_l + mixer_r ) / 2; } + + + + +
--- a/mixer.h Thu Feb 21 15:44:51 2002 +0000 +++ b/mixer.h Thu Feb 21 16:02:26 2002 +0000 @@ -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 );
--- a/mplayer.c Thu Feb 21 15:44:51 2002 +0000 +++ b/mplayer.c Thu Feb 21 16:02:26 2002 +0000 @@ -171,7 +171,7 @@ #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 @@ #endif } break; - case 'm': - mixer_usemaster=!mixer_usemaster; - break; #if 0 // change to 1 for absolute seeking tests case '1': @@ -2451,7 +2448,6 @@ #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;