changeset 6074:10a30eebafaf

Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting support. Also the dvd subtitles should work now.
author albeu
date Mon, 13 May 2002 19:57:27 +0000
parents 4afabc5571ae
children 0b3b6d03779c
files libao2/Makefile libao2/ao_dxr2.c libvo/vo_dxr2.c
diffstat 3 files changed, 54 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/Makefile	Mon May 13 19:53:16 2002 +0000
+++ b/libao2/Makefile	Mon May 13 19:57:27 2002 +0000
@@ -8,7 +8,7 @@
 
 OBJS=$(SRCS:.c=.o)
 
-CFLAGS  = $(OPTFLAGS) -I. -I.. $(SDL_INC) $(X11_INC) $(EXTRA_INC) $(DVB_INC)
+CFLAGS  = $(OPTFLAGS) -I. -I.. $(SDL_INC) $(X11_INC) $(EXTRA_INC) $(DXR2_INC) $(DVB_INC)
 
 .SUFFIXES: .c .o
 
--- a/libao2/ao_dxr2.c	Mon May 13 19:53:16 2002 +0000
+++ b/libao2/ao_dxr2.c	Mon May 13 19:57:27 2002 +0000
@@ -1,8 +1,9 @@
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <inttypes.h>
-
+#include <dxr2ioctl.h>
 #include "../config.h"
 #include "mp_msg.h"
 #include "bswap.h"
@@ -23,8 +24,40 @@
 
 LIBAO_EXTERN(dxr2)
 
+static int volume=19;
+extern int dxr2_fd;
+
 // to set/get/query special features/parameters
 static int control(int cmd,int arg){
+  switch(cmd){
+  case AOCONTROL_GET_VOLUME:
+    if(dxr2_fd > 0) {
+      ao_control_vol_t* vol = (ao_control_vol_t*)arg;
+      vol->left = vol->right = volume * 19.0 / 100.0;
+      return CONTROL_OK;
+    }
+    return CONTROL_ERROR;
+  case AOCONTROL_SET_VOLUME:
+    if(dxr2_fd > 0) {
+      dxr2_oneArg_t v;
+      float diff;
+      ao_control_vol_t* vol = (ao_control_vol_t*)arg;
+      // We need this trick because the volume stepping is often too small
+      diff = ((vol->left+vol->right) / 2 - (volume*19.0/100.0)) * 19.0 / 100.0;
+      v.arg = volume + (diff > 0 ? ceil(diff) : floor(diff)); 
+      if(v.arg > 19) v.arg = 19;
+      if(v.arg < 0) v.arg = 0;
+      if(v.arg != volume) {
+	volume = v.arg;
+	if( ioctl(dxr2_fd,DXR2_IOC_SET_AUDIO_VOLUME,&v) < 0) {
+	  mp_msg(MSGT_AO,MSGL_ERR,"DXR2 : Setting volume to %d failed\n",volume);
+	  return CONTROL_ERROR;
+	}
+      }
+      return CONTROL_OK;
+    }
+    return CONTROL_ERROR;
+  }
   return CONTROL_UNKNOWN;
 }
 
@@ -45,29 +78,32 @@
 
 	switch(rate){
 	case 48000:
-		freq_id=0;
+		freq_id=DXR2_AUDIO_FREQ_48;
 		break;
 	case 96000:
-		freq_id=1;
+		freq_id=DXR2_AUDIO_FREQ_96;
 		break;
 	case 44100:
-		freq_id=2;
+		freq_id=DXR2_AUDIO_FREQ_441;
 		break;
 	case 32000:
-		freq_id=3;
+		freq_id=DXR2_AUDIO_FREQ_32;
 		break;
 	case 22050:
-		freq_id=4;
+		freq_id=DXR2_AUDIO_FREQ_2205;
 		break;
-#if 0
+#ifdef DXR2_AUDIO_FREQ_24
+	// This is not yet in the dxr2 driver CVS
+	// you can get the patch at
+	// http://www.ranmachan.dyndns.org/~ranma/patches/dxr2.pcm1723.20020513
 	case 24000:
-		freq_id=5;
+		freq_id=DXR2_AUDIO_FREQ_24;
 		break;
 	case 64000:
-		freq_id=6;
+		freq_id=DXR2_AUDIO_FREQ_64;
 		break;
 	case 88200:
-		freq_id=7;
+		freq_id=DXR2_AUDIO_FREQ_882;
 		break;
 #endif
 	default:
@@ -128,7 +164,7 @@
 	//unsigned short *s=data;
 	uint16_t *s=data;
 #ifndef WORDS_BIGENDIAN
-	for(i=0;i<len/2;i++) s[i] = bswap_16(s[i]); // (s[i]>>8)|(s[i]<<8); // le<->be bswap_16(s[i]);
+	for(i=0;i<len/2;i++) s[i] = bswap_16(s[i]);
 #endif
 	dxr2_send_lpcm_packet(data,len,0xA0,ao_data.pts-10000,freq_id);
     }
--- a/libvo/vo_dxr2.c	Mon May 13 19:53:16 2002 +0000
+++ b/libvo/vo_dxr2.c	Mon May 13 19:57:27 2002 +0000
@@ -25,7 +25,7 @@
 extern float monitor_aspect;
 extern float movie_aspect;
 
-static int dxr2_fd = -1;
+int dxr2_fd = -1;
 
 static int movie_w,movie_h;
 static int fs = 0;
@@ -176,7 +176,7 @@
   int ptslen=5;
 
   if(dxr2_fd < 0) {
-    mp_msg(MSGT_VO,MSGL_ERR,"DXR2 isn't ready\n");
+    mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
     return;
   }
 
@@ -228,28 +228,14 @@
   int ptslen=5;
 
   if(dxr2_fd < 0) {
-    mp_msg(MSGT_VO,MSGL_ERR,"DXR2 isn't ready\n");
+    mp_msg(MSGT_VO,MSGL_ERR,"DXR2 fd is not valid\n");
     return;
   }    
 
   if(last_freq_id != freq_id) {
-    switch (freq_id) {
-    case 0: arg=DXR2_AUDIO_FREQ_48; break;
-    case 1: arg=DXR2_AUDIO_FREQ_96; break;
-    case 2: arg=DXR2_AUDIO_FREQ_441; break;
-    case 3: arg=DXR2_AUDIO_FREQ_32; break;
-    case 4: arg=DXR2_AUDIO_FREQ_2205; break;
-#if 0
-      // This is not is the dxr2 driver, but in a Tobias Diedrich patch 
-    case 5: arg=DXR2_AUDIO_FREQ_24; break;
-    case 6:  arg=DXR2_AUDIO_FREQ_64; break;
-    case 7: arg=DXR2_AUDIO_FREQ_882; break;
-#endif
-    }
-    ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &arg);
+    ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &freq_id);
     last_freq_id = freq_id;
   }
-  freq_id=0;
 
   if (((int) timestamp)<0)
     timestamp=0;
@@ -316,7 +302,7 @@
     //	   audio sampling frequency (48khz = 0, 96khz = 1)        2 bit
     //	   reserved                                               1 bit
     //	   number of audio channels - 1 (e.g. stereo = 1)         3 bit
-    pack[ptslen+14]=1|(freq_id<<4);
+    pack[ptslen+14]=1;
 
     //	   dynamic range control (0x80 if off)
     pack[ptslen+15]=0x80;
@@ -326,7 +312,6 @@
 
     len-=payload_size; data+=payload_size;
     timestamp+=90000/4*payload_size/48000;
-    //		ptslen=0; // store PTS only once, at first packet!
   }
 }
 
@@ -508,7 +493,7 @@
 static uint32_t query_format(uint32_t format)
 {
   if (format==IMGFMT_MPEGPES)
-    return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER;
+    return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER|VFCAP_SPU;
   return 0;
 }