delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2001/10/16/10:36:32

Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-apps-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/lists.html#faqs>
Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com
From: "Ralf Habacker" <Ralf DOT Habacker AT freenet DOT de>
To: <cygwin-apps AT cygwin DOT com>
Subject: RE: [ANNOUNCEMENT] cygwin patch for xfree game rocks & diamonts available
Date: Tue, 16 Oct 2001 16:39:03 +0200
Message-ID: <001d01c15650$4cef2d00$651c440a@BRAMSCHE>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-Reply-To: <20011016090023.E6725@redhat.com>

>
> 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
ioctl(SNDCTL_DSP_GETBLKSIZE...) .

Ralf

	  unsigned long fragment_spec = 0;

	  /* determine logarithm (log2) of the fragment size */
	  for (fragment_spec=0; (1 << fragment_spec) < fragment_size;
	       fragment_spec++);

	  /* 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)
	    Error(ERR_EXIT_SOUND_SERVER,
		  "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)
	    Error(ERR_EXIT_SOUND_SERVER,
		  "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)
	    Error(ERR_EXIT_SOUND_SERVER,
		  "cannot get fragment size of /dev/dsp - no sounds");

	  max_sample_size = fragment_size / (stereo ? 2 : 1);
	}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019