[MPlayer-dev-eng] Re: mencoder HEAD: tv audio recording broken?

Oswald Buddenhagen ossi at kde.org
Fri Mar 12 05:11:51 CET 2004


fwiw, i'm amazed by the amount of attention this (pretty serious to
those affected) problem is getting ...

*grmpf*

On Sun, Feb 01, 2004 at 03:36:10AM +0100, Oswald Buddenhagen wrote:
> the problem is the combination of my soundcard with liblame: my card (or
> the driver, whatever) says the actual sample rate is 44101, instead of
> 44100. as a consequence, liblame cannot handle the data:

> two consequences:
> - the attached patch: if the actual rate is within +/- 10 hz of the
>   requested rate, pretend that it is the requested rate. the 10 is
>   arbitrary - maybe it would be better to use 1, so only rounding errors
>   are caught.
> - we know that liblame cannot handle "odd" rates, so we should refuse
>   them.

Index: ai_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/ai_oss.c,v
retrieving revision 1.8
diff -U2 -r1.8 ai_oss.c
--- ai_oss.c	29 Jan 2004 12:43:54 -0000	1.8
+++ ai_oss.c	1 Feb 2004 02:33:02 -0000
@@ -24,9 +24,14 @@
 #include "mp_msg.h"
 
+#define TOL 10 /* rate tolerance for broken audio cards/drivers */
+
 int ai_oss_set_samplerate(audio_in_t *ai)
 {
     int tmp = ai->req_samplerate;
     if (ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &tmp) == -1) return -1;
-    ai->samplerate = tmp;
+    if (tmp < ai->req_samplerate - TOL || tmp > ai->req_samplerate + TOL)
+    	ai->samplerate = tmp;
+    else
+    	ai->samplerate = ai->req_samplerate;
     return 0;
 }
@@ -104,5 +109,9 @@
 	return -1;
     }
-    ai->samplerate = ioctl_param;
+    if (ioctl_param < ai->req_samplerate - TOL ||
+	ioctl_param > ai->req_samplerate + TOL)
+	ai->samplerate = ioctl_param;
+    else
+	ai->samplerate = ai->req_samplerate;
 
     mp_msg(MSGT_TV, MSGL_V, "ioctl dsp trigger: %d\n",

greetings


-- 
Chaos, panic, and disorder - my work here is done.




More information about the MPlayer-dev-eng mailing list