[ANNOUNCEMENT] cygwin patch for xfree game rocks & diamonts available
Tue Oct 16 07:34:00 GMT 2001
> On Tue, Oct 16, 2001 at 08:27:43AM +0200, Ralf Habacker wrote:
> >4. cygwin uses a fixed buffer size of 16384. r&d like to use a 512
> byte buffer,
> >which cygwin does ignore.
> > This causes delay in 1.
> That sounds fixable. How is the buffer size controlled on linux?
Below is a part from src/libgame/sound.c of the rocks&diamonds source
distribution, which initialize the sound.
The size is set with ioctl(SNDCTL_DSP_SETFRAGMENT...) and later recalled with
unsigned long fragment_spec = 0;
/* determine logarithm (log2) of the fragment size */
for (fragment_spec=0; (1 << fragment_spec) < fragment_size;
/* use two fragments (play one fragment, prepare the other);
one fragment would result in interrupted audio output, more
than two fragments would raise audio output latency to much */
fragment_spec |= 0x00020000;
/* Example for fragment specification:
- 2 buffers / 512 bytes (giving 1/16 second resolution for 8 kHz)
- (with stereo the effective buffer size will shrink to 256)
=> fragment_size = 0x00020009 */
if (ioctl(audio.device_fd,SNDCTL_DSP_SETFRAGMENT,&fragment_spec) < 0)
"cannot set fragment size of /dev/dsp - no sounds");
/* try if we can use stereo sound */
if (ioctl(audio.device_fd, SNDCTL_DSP_STEREO, &stereo) < 0)
if (ioctl(audio.device_fd, SNDCTL_DSP_SPEED, &sample_rate) < 0)
"cannot set sample rate of /dev/dsp - no sounds");
/* get the real fragmentation size; this should return 512 */
if (ioctl(audio.device_fd, SNDCTL_DSP_GETBLKSIZE,&fragment_size) < 0)
"cannot get fragment size of /dev/dsp - no sounds");
max_sample_size = fragment_size / (stereo ? 2 : 1);
More information about the Cygwin-apps