[MPlayer-dev-eng] [PATCH] use of mixer with -ao nas

Nguyen Kim nguyenk at ie2.u-psud.fr
Tue Nov 19 09:51:29 CET 2002


Hi list,
this is a simple a simple patch which allow
the use of mixer with -ao nas.
As this is my first patch, tell me if something goes wrong.
Kind regards.
K.N.
-------------- next part --------------
Index: libao2/ao_nas.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_nas.c,v
retrieving revision 1.10
diff -u -r1.10 ao_nas.c
--- libao2/ao_nas.c	13 Oct 2002 22:00:15 -0000	1.10
+++ libao2/ao_nas.c	19 Nov 2002 08:48:41 -0000
@@ -334,7 +334,41 @@
 
 // to set/get/query special features/parameters
 static int control(int cmd,int arg){
-	return -1;
+  AuDeviceAttributes * dattr;
+  int gain;
+  AuFixedPoint fpgain;
+  AuStatus ret_stat;
+  dattr = AuGetDeviceAttributes(nas_data->aud,nas_data->dev,&ret_stat);
+  //kn: 0<= gain <=100
+  gain = AuFixedPointRoundDown(AuDeviceGain(dattr));
+  switch (cmd){
+  case AOCONTROL_GET_VOLUME:
+  case AOCONTROL_SET_VOLUME:
+    {
+      ao_control_vol_t * vol = (ao_control_vol_t *)arg;
+      if (cmd == AOCONTROL_GET_VOLUME){
+	vol->right =(float) gain;
+	vol->left = vol->right;
+      }
+      else{ 
+	/*kn: we should have vol->left == vol->right but i don't 
+	  know if something can change it outside of ao_nas 
+	  so i take the mean of both values.*/
+	gain = (int) ((vol->left+vol->right)/2);
+	
+	fpgain = AuFixedPointFromSum( gain,0xFF);
+	AuDeviceGain(dattr) = fpgain;	
+	AuSetDeviceAttributes(nas_data->aud,nas_data->dev,AuCompDeviceGainMask,dattr,&ret_stat);	
+	
+      };
+      if (ret_stat==AuSuccess)
+	return CONTROL_OK;
+      else 
+	return CONTROL_ERROR;
+    }
+  default:
+    return -1;
+  };
 }
 
 // open & setup audio device


More information about the MPlayer-dev-eng mailing list