[Mplayer-cvslog] CVS: main/libao2 Makefile,1.18,1.19 ao_mpegpes.c,1.5,1.6 ao_oss.c,1.17,1.18 ao_sun.c,1.12,1.13 audio_out.c,1.21,1.22

Anders Johansson anders at mplayer.dev.hu
Thu Feb 21 17:02:29 CET 2002


Update of /cvsroot/mplayer/main/libao2
In directory mplayer:/var/tmp.root/cvs-serv11301/libao2

Modified Files:
	Makefile ao_mpegpes.c ao_oss.c ao_sun.c audio_out.c 
Log Message:
Moved HW dependent mixer stuff to libao and removed master switch

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/Makefile,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Makefile	20 Dec 2001 15:30:20 -0000	1.18
+++ Makefile	21 Feb 2002 16:02:26 -0000	1.19
@@ -4,7 +4,7 @@
 LIBNAME = libao2.a
 
 # TODO: moveout ao_sdl.c so it's only used when SDL is detected
-SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c $(OPTIONAL_SRCS)
+SRCS=afmt.c audio_out.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c $(OPTIONAL_SRCS)
 
 OBJS=$(SRCS:.c=.o)
 

Index: ao_mpegpes.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_mpegpes.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ao_mpegpes.c	24 Jan 2002 00:53:22 -0000	1.5
+++ ao_mpegpes.c	21 Feb 2002 16:02:26 -0000	1.6
@@ -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;

Index: ao_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_oss.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ao_oss.c	15 Jan 2002 22:55:28 -0000	1.17
+++ ao_oss.c	21 Feb 2002 16:02:26 -0000	1.18
@@ -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 (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;
 	    }
@@ -102,6 +94,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);

Index: ao_sun.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sun.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ao_sun.c	14 Dec 2001 20:13:17 -0000	1.12
+++ ao_sun.c	21 Feb 2002 16:02:26 -0000	1.13
@@ -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;
 }
@@ -224,6 +257,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)

Index: audio_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- audio_out.c	11 Jan 2002 22:30:48 -0000	1.21
+++ audio_out.c	21 Feb 2002 16:02:26 -0000	1.22
@@ -34,8 +34,10 @@
 #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 @@
 #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




More information about the MPlayer-cvslog mailing list