From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 9 Feb 1997 17:35:21 -0500 From: rsc@research.att.com rsc@research.att.com Subject: pc audio buffer bug Topicbox-Message-UUID: 55072454-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19970209223521.so3USmZnwgx59yb6fmkP2IGrAjOSrY0fKmYCynvnuZc@z> 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