9fans archive / 1997 / 02 / 5 / prev next
From: rsc@res... rsc@res...
Subject: pc audio buffer bug
Date: Sun, 9 Feb 1997 17:35:21 -0500
There is a small bug in the buffer handling
in the PC devaudio (Soundblaster) driver.
Basically, if you open /dev/audio for writing,
partially fill a buffer, and then close /dev/audio,
the buffer doesn't get played. You notice this
with smallish sound files, because nothing gets
played at all when the sound file is less than one
buffer in size.
My fix is to add
int omode;
Buf *b;
at the beginning of
/sys/src/9/pc/devaudio.c:/^audioclose
and in the case Qaudio that follows, insert
omode = audio.amode;
before audio.amode = Aclosed;
Then, before the while(audio.active), insert
if(omode == Awrite && audio.filling != 0) {
print("flush...");
b = audio.filling;
audio.filling = 0;
memset(b->virt+audio.curcount, 0, Bufsize-audio.curcount);
swab(b->virt);
putbuf(&audio.full, b);
pokeaudio();
}
I would post a diff, but I've hacked up devaudio.c
too much. Just looking at the code for other
architectures, it appears that next/devaudio.c also
suffers from this bug, while indigo3k/devaudio.c
does not.
Russ