diff options
author | anders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-02-21 16:02:26 +0000 |
---|---|---|
committer | anders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-02-21 16:02:26 +0000 |
commit | ee2ed8567e3401469fcf13eb96e42d79c4b32714 (patch) | |
tree | 90bb902bb5f99813bba6b2bd07ff6620a0d39e0a /libao2 | |
parent | ea1d75800931055c8a04cf76e8b6c914c2ed3e23 (diff) | |
download | mpv-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 'libao2')
-rw-r--r-- | libao2/ao_mpegpes.c | 34 | ||||
-rw-r--r-- | libao2/ao_oss.c | 39 | ||||
-rw-r--r-- | libao2/ao_sun.c | 36 | ||||
-rw-r--r-- | libao2/audio_out.c | 8 |
4 files changed, 92 insertions, 25 deletions
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 |