[ltp] How to eliminate the clicks

Thomas Hood linux-thinkpad@www.bm-soft.com
Wed, 24 Nov 1999 23:46:16 -0500


There was some discussion recently in the linux-tp600 list
about the problem of the "click" that follows each sound
effect.  One solution proposed was to give the "-as 100000"
option to esd so that it would keep the sound device open
for a long time (100000 seconds) after playing something.
This solution has some drawbacks.  The first is that so
long as the sound device is open, suspend is inhibited.
The second is that KDE users are using kaudioserver,
not esd, and kaudioserver does not have anything like
an "-as" option.

The proper solution is to eliminate the click by fixing
the audio driver.  I have managed to do this to the ALSA
driver for the CS4237B in my ThinkPad 600.  No more click.

The fix is to remove a section of code from the function
snd_cs4231_close() in the file 
.../alsa-driver-0.4.1e/lowlevel/isa/cs4231.c .
I show here the section of code in question, removed by
slapping "#if 0 ... #endif" around it:

-----------------------------------------------------
#if 0
        /* now disable record & playback */
        snd_cs4231_mce_up(codec);
        spin_lock_irqsave(&codec->reg_lock, flags);
        codec->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE |
CS4231_PLAYBACK_PIO |
                             CS4231_RECORD_ENABLE | CS4231_RECORD_PIO);
        snd_cs4231_out(codec, CS4231_IFACE_CTRL,
codec->image[CS4231_IFACE_CTRL]);
        spin_unlock_irqrestore(&codec->reg_lock, flags);
        snd_cs4231_mce_down(codec);
#endif                                                                          
------------------------------------------------------

CAVEAT: I don't really know what all the implications are
of removing this bit of code.  It's a total hack.  Nevertheless
my intuition tells me that not "disabling record and playback"
when the device file is closed is no big deal.  Record and
playback will just be enabled again when the device is opened,
the next time it is needed.

It seems to work, and the clicks are gone.

Thomas Hood
jdthood@mail.com
----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html