[MPlayer-dev-eng] [PATCH] oss mixer into ao_arts.c

gpanco - gpanco at tiscali.it
Mon Oct 20 16:46:25 CEST 2003


rebuild patch with cvs version and patch -Naur.


-------------- next part --------------
diff -Naur main/libao2/ao_arts.c main.my/libao2/ao_arts.c
--- main/libao2/ao_arts.c	2003-03-21 17:42:50.000000000 +0100
+++ main.my/libao2/ao_arts.c	2003-10-20 16:40:41.000000000 +0200
@@ -10,12 +10,26 @@
 #include <artsc.h>
 #include <stdio.h>
 
+#include <stdlib.h>
+
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/soundcard.h>
+
 #include "audio_out.h"
 #include "audio_out_internal.h"
 #include "afmt.h"
 #include "../config.h"
 #include "../mp_msg.h"
 
+#include "../mixer.h"
+
 #define OBTAIN_BITRATE(a) (((a != AFMT_U8) && (a != AFMT_S8)) ? 16 : 8)
 
 /* Feel free to experiment with the following values: */
@@ -34,11 +48,63 @@
 
 LIBAO_EXTERN(arts)
 
-static int control(int cmd, void *arg)
-{
-	return(CONTROL_UNKNOWN);
+// copied as-is from ao_oss.c
+// 
+static char *dsp=PATH_DEV_DSP;
+static char *oss_mixer_device = PATH_DEV_MIXER;
+
+// to set/get/query special features/parameters
+static int control(int cmd,void *arg){
+    switch(cmd){
+	case AOCONTROL_SET_DEVICE:
+	    dsp=(char*)arg;
+	    return CONTROL_OK;
+	case AOCONTROL_GET_DEVICE:
+	    (char*)arg=dsp;
+	    return CONTROL_OK;
+	case AOCONTROL_QUERY_FORMAT:
+	    return CONTROL_TRUE;
+	case AOCONTROL_GET_VOLUME:
+	case AOCONTROL_SET_VOLUME:
+	{
+	    ao_control_vol_t *vol = (ao_control_vol_t *)arg;
+	    int fd, v, devs;
+
+	    if(ao_data.format == AFMT_AC3)
+		return CONTROL_TRUE;
+    
+	    if ((fd = open(oss_mixer_device, O_RDONLY)) > 0)
+	    {
+		ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
+		if (devs & SOUND_MASK_PCM)
+		{
+		    if (cmd == AOCONTROL_GET_VOLUME)
+		    {
+		        ioctl(fd, SOUND_MIXER_READ_PCM, &v);
+			vol->right = (v & 0xFF00) >> 8;
+			vol->left = v & 0x00FF;
+		    }
+		    else
+		    {
+		        v = ((int)vol->right << 8) | (int)vol->left;
+			ioctl(fd, SOUND_MIXER_WRITE_PCM, &v);
+		    }
+		}
+		else
+		{
+		    close(fd);
+		    return CONTROL_ERROR;
+		}
+		close(fd);
+		return CONTROL_OK;
+	    }
+	}
+	return CONTROL_ERROR;
+    }
+    return CONTROL_UNKNOWN;
 }
 
+
 static int init(int rate_hz, int channels, int format, int flags)
 {
 	int err;


More information about the MPlayer-dev-eng mailing list