[MPlayer-dev-eng] audio mixer
Anders Johansson
ajh at atri.curtin.edu.au
Thu Feb 21 15:04:35 CET 2002
Look who forgets to attach patches, everybody point at Anders and
laugh.
//Anders
-------------- next part --------------
--- ../../main.dev/libao2/ao_mpegpes.c Sun Jan 27 18:32:59 2002
+++ ao_mpegpes.c Thu Feb 21 21:46:17 2002
@@ -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;
-------------- next part --------------
--- ../../main.dev/libao2/ao_sun.c Thu Dec 20 16:37:53 2001
+++ ao_sun.c Thu Feb 21 21:44:58 2002
@@ -42,6 +42,8 @@
#endif
+static char *mixer_device="/dev/audioctl";
+static int mixer_usemaster=0;
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( 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( 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;
}
More information about the MPlayer-dev-eng
mailing list