[MPlayer-dev-eng] [PATCH] Re: Software AC3 Decoding with CM8738

Eric Lammerts eric at lammerts.org
Sun May 12 19:04:37 CEST 2002


Arpi wrote:
>Stefan Lange wrote:
>> I'm experiencing a weird situation when I'm playing files with
>> AC3-audio with mplayer. I'm using the analog outputs of my
>> soundcard (CMedia CM 8783) with mplayer's software AC3 decoder.
>> Playing back 5.1-sound with "-channels=6" works fine, but if I
>> pause and unpause during playback, channels are switched. For
>> example:
>>
>> Start playing (center output comes from center) --> pause -->
>> unpause --> center comes from front left or rear left

I have the same problem.

>i assume you're using oss (cannot see mplayer -v log here)
>the oss driver re-opens device at pause, as described in oss specs.
>
>it's probably a driver bug, it may swap channels at reopen?

It's a bug in ao_oss.c. When it's playing 6 channels, it should write
in multiples of 12 bytes, otherwise things get messed up at
close/reopen.

Here's a fix.

Eric

Index: libao2/ao_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_oss.c,v
retrieving revision 1.23
diff -u -r1.23 ao_oss.c
--- libao2/ao_oss.c	29 Apr 2002 20:42:15 -0000	1.23
+++ libao2/ao_oss.c	12 May 2002 17:06:05 -0000
@@ -91,6 +91,8 @@
 // return: 1=success 0=fail
 static int init(int rate,int channels,int format,int flags){

+  int bytes_per_sample;
+
   printf("ao2: %d Hz  %d chans  %s\n",rate,channels,
     audio_out_format_name(format));

@@ -122,8 +124,11 @@
 #endif

   ao_data.bps=channels*rate;
-  if(format != AFMT_U8 && format != AFMT_S8)
+  bytes_per_sample=channels;
+  if(format != AFMT_U8 && format != AFMT_S8) {
     ao_data.bps*=2;
+    bytes_per_sample*=2;
+  }

   if(format == AFMT_AC3) {
     ao_data.samplerate=rate;
@@ -184,6 +189,7 @@
       if(ao_data.buffersize==-1) ao_data.buffersize=zz.bytes;
       ao_data.outburst=zz.fragsize;
   }
+  ao_data.outburst-=ao_data.outburst % bytes_per_sample; // round down

   if(ao_data.buffersize==-1){
     // Measuring buffer size:




More information about the MPlayer-dev-eng mailing list