[alsa-devel] Bug report Realtek ALC887-VD HDA Intel tone://15000

Mihai Moise mihai.moise5 at gmail.com
Thu Oct 24 21:12:47 CEST 2013

This e-mail might not be threaded well. It is a follow-up to:


I found what causes the ALSA bug I wrote about on 10 Oct. aplay uses this:

Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Plug PCM: Rate conversion PCM (48000, sformat=S32_LE)
Converter: linear-interpolation

It is located at alsa-lib-
It apears to be a resampler with linear interpolation.

The bug I wrote about is caused because linear interpolation is not
good. I don't mean that there is a programming error. I mean that the
mathematical theory is flawed.

Linux-3.12-rc4 has a resampler at sound/core/oss/rate.c which I'm
guessing is ALSA's OSS compatibility layer (OSS for short). It uses
linear interpolation and is mathematically equivalent to the alsa-libs
resampler. Then it should sound as bad, but the OSS driver in my
Slackware-64 14, which is ALSA's OSS compatibility layer, sounds
inexplicably good even on a sine generator. So I started thinking that
ALSA's OSS compatibility layer puts the Realtek ALC887-VD in 44.1 KHz

I have been messing up linux-3.12-rc4 adding printk(KERN_ERRs to see
where the code goes through and changing the ALSA's OSS resamplers
so they only play garbage sound. But my song still sounds good when
played with sox's option -r 44100 -t oss -d So far, everything has
held up to my hypothesis.

I added this line to

                u32 rates = 0;
                for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) {
                        if (val & (1 << i))
                                rates |= rate_bits[i].alsa_bits;
                printk(KERN_ERR "mihai rates = %d decimal\n", rates);


mihai rates = 5312 decimal
mihai rates = 5856 decimal

I don't know what these numbers mean. According to
linux-3.12-rc4/include/sound/pcm.h that would mean 192KHz. So that's
not the interpretation.

I added this line to linux-3.12-rc4/sound/core/oss/rate.c:resample_expand:

printk(KERN_ERR "Entered resample_expand\n");

Result: nothing in /var/log/syslog, even after playing 44.1KHz audio
through sox's option -r 44100 -t oss -d

I added this line to linux-3.12-rc4/sound/core/oss/rate.c:resample_shrink:

printk(KERN_ERR "Entered resample_shrink\n");

Result: nothing in /var/log/syslog

I made  linux-3.12-rc4/sound/core/oss/rate.c:resample_expand play
garbage audio like this:

                        *dst = val;
                        if(((long)dst) & 4) *dst = 32767;
                        else *dst = -32767;
                        dst += dst_step;

And I made linux-3.12-rc4/sound/core/oss/rate.c:resample_shrink play
garbage audio like this:

                                *dst = val;
                                if(((long)dst) & 4) *dst = 32767;
                                else *dst = -32767;
                                dst += dst_step;

Result: playing a 44.1KHz song through sox's option -r 44100 -t oss -d
plays just fine.

I would appreciate if someone would clarify me if ALSA's OSS
compatibility layer puts the Realtek ALC887-VD in 44.1KHz mode.

More information about the Alsa-devel mailing list