Re: FreeBSD sound distortion problems with SB Live! fixed with PREEMPTION

From: Jeremie Le Hen <jeremie_at_le-hen.org>
Date: Wed, 8 Dec 2004 09:56:00 +0100
[ freebsd-stabl_at_ is now the right place for RELENG_5 ].

On Tue, Dec 07, 2004 at 11:48:40PM -0700, Travis Poppe wrote:
> Hello all,
> 
> Back in October, I contacted the list and described a problem I was
> having with FreeBSD 5.X (now 5.3-RELEASE) and sound. I will reiterate
> the problem one more time for those of you who did not follow the posts.
> 
> I was using FreeBSD 5.3-BETA7 at the time (as far as I know, all of 5.x
> has this problem) and have an SB Live! 5.1 which uses the emu10k1
> driver. I've been told that this problem may be specific to my driver
> (and possibly others).
> 
> The problem:
> 
> When playing music with XMMS after my box had been up for at least a day
> or two, I'd hear these "random" skips and sound distortions that can be
> described as the sound being slowed down for 1/4th of a second and then
> back to normal again (a "lagged sound" skip). 

I have *exactly* the same problem on a 5.3 box (branch RELENG_5 after
RELENG_5_3_BP).
FreeBSD obiwan 5.3-STABLE FreeBSD 5.3-STABLE #3: Sun Nov 21 17:22:54 CET 2004     root_at_obiwan:/usr/src/sys/i386/compile/OBIWAN  i386

> A much more severe version of this can easily be reproduced by
> extracting the firefox source code from bz2 while playing music and can
> be witnessed for as long as it takes to extract the archive. Note that
> these are not just "skips" but complete sound distortion as well. If you
> hear very minor brief skips when running this test but no distortion,
> you are not witnessing the same problem.
> 
> In the previous posts to -CURRENT, I was advised to increase the sound
> buffer which did HELP, but the problem was still there. Increasing the
> buffer also caused de-synced sound in games. This was not a good
> workaround.
> 
> Anyway, today I was playing around with a few patches derived from
> DragonFly that make it possible to use high resolution VESA modes with
> syscons. I was using a 1024x768 VESA text console when I noticed that if
> a lot of text were to be scrolled on the screen at once, I'd hear the
> same sound problem described above.
> 
> Frustrated, I began conversation on IRC and described my problem. A
> friend of mine suggested something no one else had before, and that
> suggestion was to enable PREEMPTION in the kernel. A GNU/Linux user in
> another channel also said this to me: "Sounds like FreeBSD needs a
> preemptable kernel." So, I decided to give it a try.
> 
> To my amazement, it worked completely. Enabling PREEMPTION in the kernel
> completely "fixes" this problem to the fullest extent. I have not been
> able to reproduce the problem since using any of the methods described
> above.
> 
> I'm hoping that with this new information someone might be able to
> figure out what is truly causing this problem and can come up with a
> solution (or is PREEMPTION a good solution?). It seems that only a
> handful of drivers (emu10k1 is the one I'm having problems with) have
> this problem. For the record, I am not the only one who has reported
> this problem to the lists.

You make me happy !  I noticed this problem yesterday evening, and I
did'nt have time to investigate yet.  It definitely seems that
PREEMPTION is the good solution since these small "breaks" in sounds
indicates that, coarsely, the kernel does not "have enough time" to
do what it wants between two sound frames.  Basically, PREEMPTION
allows to interrupt the kernel in its current task if there is something
more important to do, like pushing a new sound frame.  (If someone wants
to make a more precise description -- or even correct me if I'm wrong --,
I would be graceful.)

FIY, Linux folks have a dedicated preemption patch which was initially
started to make things such as Jack Audio Connection Kit [1] and related
softwares work fine.

Regards, 

[1] http://jackit.sf.net/
-- 
Jeremie Le Hen
jeremie_at_le-hen.org
Received on Wed Dec 08 2004 - 07:57:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:24 UTC