recently I've been abusing my remote desktop system by listening to
music over it (i know it sounds dumb, but just work with me here). It
worked just fine, sounded great. However I noticed that my CPU (Athlon
XP2100) was pegged with the rdesktop (v1.4.1) process, and mostly
system time rather than user. An strace eventually let me to the ioctl
on line 258 or rdpsnd_oss.c, which was being called a whole lot. So, not
being familiar with the OSS interface or with rdesktop internals (and so
not really knowing what most of that code is for), wanting to make
minimal changes, and just wanting it to work, i just changed the if
statement above it (line 255) to be always false, rebuilt, and it worked
Later, i switched from my Audigy 2 to the AC97 chip on the motherboard.
Now, using the modified version, the sound plays with popping/cracking,
and the original code works as it did before, with good sound and high
CPU utilization (presumably that's why that code was there).
So then, i set up a simple counter and only called the ioctl, say every
15th call (i just randomly made up that number) into the wave_out_play
function. This rate-limiting does keep CPU use low, but pops/cracks
still occasionally come and go.
So... can anyone explain to me what this code is for? (relevant code
snippet pasted at bottom). I'd be willing to do some work on it, but as
I said i'm not too familiar with the OSS API or with rdesktop internals.
can someone point me in the right direction?
oh btw, the system is running current Debian Etch (testing), with its
default 2.6.12-1-k7 kernel
here's the relevant code (the original code from 1.4.1):
memset(&info, 0, sizeof(info));
if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
if (info.fragments == 0)
g_dsp_busy = 1;
if (info.fragments * info.fragsize < len
&& info.fragments * info.fragsize > 0)
len = info.fragments * info.fragsize;
len = write(g_dsp_fd, out->p, len); // <- that's the write to
the sound device