From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 10 Feb 1997 20:52:49 +1100 From: David Hogan dhog@cs.su.oz.au Subject: pc audio buffer bug Topicbox-Message-UUID: 556fbf28-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19970210095249.SUPa7841whaY05_XhhFU4Y_zC7EYnjE_ZQJ4kUNFzxA@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. I seem to recall that there was another bug. I can't remember if I posted my fix for it or not. The problem was that you could fill up several buffers, but still get no audio, because you hadn't filled enough buffers to start the dma going. It looks like Russ's patch comes close to fixing this bug as well (by virtue of the call to pokeaudio()). But if the combined writes to /dev/audio are a multiple of Bufsize, then it won't be called, because audio.filling == 0. My fix to this second bug was to change the while loop in audioclose() to be do waitaudio(); while (audio.active); and change waitaudio() by adding the lines if (audio.active == 0) return; before the tsleep(). I'm a bit concerned that I may have `done bad' -- my solution can result in redundant commands being sent to the 'blaster (``start! stop!'') if there's no outstanding data. But it was, after all, a quick hack so I could get back to the more important work of playing with Csound :-)