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: Iain Sandoe (iain_AT_sandoe.co.uk)
Date: Sat Feb 17 2001 - 09:43:33 EET


Sat, Feb 17, 2001, Conrad Parker wrote:
> On Fri, Feb 16, 2001 at 03:46:40PM +0000, Iain Sandoe wrote:
>> I'm getting a little confused by odd bits of code I see which do this:

These bits of code are *not* written by me... but by people who have
considerable Linux experience... hence the question...

1/
>> val = 256 ; (or some other number)
>> ioctl(SNDCTL_DSP_SETFRAGMENTS, &val) ;

2/
>> 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).

as in val = nnnnsss
ioctl(fd, ..., &val)...

this is the question:::
>> 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]

... 1

> 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.

well, you & I agree then. However, I've seen the coding "error" more than
once (by different authors in completely different apps) and therefore I
thought the question worth asking.

>> (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?

nope... for that particular example.... (and actually for any other roughly
in the same pattern) the driver will use the minimum number of buffers it
can - and they will be of the the maximum size...

Iain


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 - 10:03:54 EET