Re: [linux-audio-dev] OSS SETFRAGMENTS

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] OSS SETFRAGMENTS
From: Conrad Parker (conradp_AT_cse.unsw.EDU.AU)
Date: Sat Feb 17 2001 - 06:05:47 EET


On Fri, Feb 16, 2001 at 03:46:40PM +0000, Iain Sandoe wrote:
> Hello,
>
> I'm getting a little confused by odd bits of code I see which do this:
>
> val = 256 ; (or some other number)
> ioctl(SNDCTL_DSP_SETFRAGMENTS, &val) ;
>
> my reading of the OSS manual (1.1) says that the arg to SETFRAGMENTS is
>
> NNNNSSSS where NNNN is the number of fragments and SSSS is log2(frag size).
>
> Am I missing an "escape" or some other "accepted" practice that means that
> the first method will work with some hardware?

[what first method? you only describe one]

the OSS drivers use a circular list of buffer "fragments". You can ask
to set the number of fragments used, and the size of each fragment. So,
lets say you want 16 fragments, each 512 bytes in size.

  N = 16; /* number. of fragments */
  S = 9; /* each of size 512 = 2 ^ 9 ; ie. log2(512) = 9 */
  
  /* Set val by fiddling bits to form NNNNSSSS in hex */
  val = (N << 16) | S;
  ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &val);

If you are setting val to 256: 256 = 0x00000100
                                   = (0 << 16) | 0x0100

ie. N = 0, S = 256, and you are asking for no buffers, each of size
2^256 bytes. If you are doing this, it is likely that the driver would
ignore the request.
 
> (it won't BTW with the PMac driver I've been working on... well it won't
> crash but it won't behave as the author presumably intended).

Does it just get ignored or does it create wierd sounds?

the OSS manual says that it's up to the driver to choose to use the
sizes you request, and in particular that a "large number of audio
devices use fixed fragment size and it's possible that this ioctl has
no effect".

Conrad.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sat Feb 17 2001 - 06:33:52 EET