[mythtv] Patch to fix lame error -3

Tamas Vincze tom at vincze.org
Tue Sep 23 16:12:30 EDT 2003


Hi,

After adding a second soundcard to capture audio I started to get
the "lame error '-3', exiting" messages. The card uses the es1371.o
kernel driver. Searching the archives showed that a couple of other
folks had the same problem and they fixed it by switching to ALSA
or using a different sampling rate. I didn't want to do either so
here's the patch to fix this issue.

The problem was that the ioctl call to set the samplerate returned
an invalid value in the audio_samplerate variable which is then
used to set the lame sampling rate. lame_init_params() returned
with an error code trying to tell us that something's wrong but
it was ignored, resulting in an uninitialized lame structure which
caused the error -3 later.

BTW the requested sampling rate was 44100, after SNDCTL_DSP_SPEED
ioctl it became 44101. It is caused by loosing the fractions after
integer divisions done in the es1371.c kernel driver:

static void set_adc_rate(struct es1371_state *s, unsigned rate)
{
	unsigned int n, truncm, freq;
	n = rate / 3000;                            // = 14
	if( (1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9)) )
		n--;
	truncm = (21 * n - 1) | 1;                  // = 293
        freq = ((48000UL << 15) / rate) * n;        // = 499310
	s->adcrate = (48000UL << 15) / (freq / n);  // = 44101
}

The ALSA driver uses exactly the same calculation to set the ADC
rate but it doesn't return the wrong value.

Best,
Tamas


-------------- next part --------------
A non-text attachment was scrubbed...
Name: es1371.patch
Type: application/octet-stream
Size: 1176 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20030923/d26901f7/es1371.obj


More information about the mythtv-dev mailing list