[Mplayer-dvb] mpegpes audio output broken

Stefan Baehre ste.ba at gmx.de
Mon Feb 3 16:11:15 CET 2003


Hi,

for me mpegpes audio output doesn't work anymore with my DVB card
(driver version 0.9.4, 03.08.2002). I have an external AC3 decoder
(Yamaha DSP-E800) connected to the card and all I hear is digital
noise. The decoder doesn't recognize a digital audio stream and plays
it back as analog instead.

The lastest working version I know of is 0.90pre8. The problem is in
the libao2/ao_mpegpes.c file. If I simply replace this file in the
current CVS version with the one from 0.90pre8, all works fine again.

I added a diff from the old ao_mpegpes.c to the current one. Maybe
anyone knows, which change might be responsible for this.

Stefan

-- 
Stefan Baehre
ste.ba at gmx.de
-------------- next part --------------
--- old/libao2/ao_mpegpes.c	2002-09-26 01:24:21.000000000 +0200
+++ main/libao2/ao_mpegpes.c	2002-12-28 13:04:57.000000000 +0100
@@ -1,6 +1,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef DVB_HEAD
+#define HAVE_DVB 1
+#endif
+
 #ifdef HAVE_DVB
 #include <sys/ioctl.h>
 #endif
@@ -15,11 +19,16 @@
 #include "../mp_msg.h"
 
 #ifdef HAVE_DVB
+#ifndef HAVE_DVB_HEAD
 #include <ost/audio.h>
 audioMixer_t dvb_mixer={255,255};
+#else
+#include </linux/dvb/audio.h>
+audio_mixer_t dvb_mixer={255,255};
+#endif
+#endif
 extern int vo_mpegpes_fd;
 extern int vo_mpegpes_fd2;
-#endif
 
 #include <errno.h>
 
@@ -76,20 +85,46 @@
 // return: 1=success 0=fail
 static int init(int rate,int channels,int format,int flags){
 
+#ifdef HAVE_DVB
+    if(vo_mpegpes_fd2<0) return 0; // couldn't open audio dev
+#else
+    if(vo_mpegpes_fd<0) return 0; // no file
+#endif
+
+    ao_data.channels=2;
     ao_data.outburst=2000;
-    ao_data.format=format;
-freq=rate;
+    switch(format){
+	case AFMT_S16_LE:
+	case AFMT_S16_BE:
+	case AFMT_MPEG:
+	    ao_data.format=format;
+	    break;
+	default:
+	    ao_data.format=AFMT_S16_BE;
+    }
     
+retry:
     switch(rate){
 	case 48000:	freq_id=0;break;
 	case 96000:	freq_id=1;break;
 	case 44100:	freq_id=2;break;
 	case 32000:	freq_id=3;break;
 	default:
-	    mp_msg(MSGT_AO, MSGL_ERR, "ao_mpegpes: %d Hz not supported, try to resample (RTFM)\n",rate);
-	    return 0;
+	    mp_msg(MSGT_AO, MSGL_ERR, "ao_mpegpes: %d Hz not supported, try to resample...\n",rate);
+#if 0
+	    if(rate>48000) rate=96000; else
+	    if(rate>44100) rate=48000; else
+	    if(rate>32000) rate=44100; else
+	    rate=32000;
+	    goto retry;
+#else
+	    rate=48000; freq_id=0;
+#endif
     }
 
+    ao_data.bps=rate*2*2;
+    freq=ao_data.samplerate=rate;
+
     return 1;
 }
 
@@ -123,6 +158,7 @@
 static int get_space(){
     float x=(float)(vo_pts-ao_data.pts)/90000.0;
     int y;
+//    printf("vo_pts: %5.3f  ao_pts: %5.3f\n",vo_pts/90000.0,ao_data.pts/90000.0);
     if(x<=0) return 0;
     y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst;
     if(y>32000) y=32000;
@@ -134,6 +170,7 @@
 // it should round it down to outburst*n
 // return: number of bytes played
 static int play(void* data,int len,int flags){
+//    printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id);
     if(ao_data.format==AFMT_MPEG)
 	send_pes_packet(data,len,0x1C0,ao_data.pts);
     else {
@@ -141,7 +178,8 @@
 	unsigned short *s=data;
 //	if(len>2000) len=2000;
 //	printf("ao_mpegpes: len=%d  \n",len);
-	for(i=0;i<len/2;i++) s[i]=(s[i]>>8)|(s[i]<<8); // le<->be
+	if(ao_data.format==AFMT_S16_LE)
+	    for(i=0;i<len/2;i++) s[i]=(s[i]>>8)|(s[i]<<8); // le<->be
 	send_lpcm_packet(data,len,0xA0,ao_data.pts,freq_id);
     }
     return len;


More information about the MPlayer-dvb mailing list