Re: [linux-audio-dev] fragmentcount ioctl with - 1?

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

Subject: Re: [linux-audio-dev] fragmentcount ioctl with - 1?
From: Hannu Savolainen (hannu_AT_opensound.com)
Date: Fri Sep 08 2000 - 14:20:50 EEST


Hi,

I think the problem is related with a workaround that was required with
some older soundcards. They raised an interrupt too early before the last
samples of the "finished" fragment were actually read from the
memory. Because of this some samples got overwritten too early which
caused clicking. The only way to prevent this was to delay reuse of the
buffer fragment until next interrupt.

As the result one extra fragment was
allocated. So when the application asks for 2 fragments the driver
allocates 3 of them. One of them is always empty and only the remaining
two are available for the application. The problem is that the
SNDCTL_DSP_GET[IO]SPACE call reports this extra fragment too (it should
report just 2).

On Fri, 8 Sep 2000, Benno Senoner wrote:

> yes,
> I discovered this problem sometime ago,
> and noticed that the ALSA OSS emulation behaves correctly,
> (eg. requesting 3 fragments in OSS/Free gives you 2 real fragments,
> while ALSA OSS emulation gives you the correct number (3)).
>
> One possiblity would be to check the num of real fragments
> after the ioctl, and then in the the case that it varies,
> try again with fragmentnum+1.
>
> But I am thinkning about all the legacy apps out here:
> not all are sensitive to the number of fragments, but in
> some case where you must rely on the effective latency
> (because you mix or sync with/to external sources),
> then it would be nice if ALSA and OSS/Free behaved correctly.
>
> So the possiblities are: fix OSS so that it uses the requested
> num of fragments, or modify the ALSA OSS emulation so that
> it behaves just like OSS (allocating num_requested_fragments -1 )
> but then, I believe that commercial OSS ( 4front-tech),
> behaves like ALSA too.
>
> what would in your opinion be the best way to achieve that
> OSS/Free, OSS and ALSA OSS-emulation behave identically ?
>
> better to fix the semantics (and potentially break some legacy apps
> (which are sensitive to latency changes), or modify the API specs
> so that the offical behaviour is
> num of real fragments = num of requested fragments -1
>
> cheers,
> Benno.
>
>
> On Thu, 07 Sep 2000, Stefan Westerfeld wrote:
> > Hi!
> >
> > I just found out that if I try to initialize the fragment count/size, then my
> > code is currently always wrong by 1. It seems that when using
> >
> > ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, 0xMMMMSSSS);
> >
> > then 2^SSSS is the usual fragment value, whereas MMMM is the number of
> > fragments MINUS 1. Can anybody confirm this MINUS 1 (didn't find it in
> > the docs), or is MMMM really supposed to be the number of fragments, and
> > its just that the driver is wrong here?
> >
> > To illustrate: ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, 0x0002000a) gives
> > me 3 (!) fragments with 1024 (2^10) bytes. Using 0x0001000a gives me
> > 2 fragments.
> >
> > Cu... Stefan
> > --
> > -* Stefan Westerfeld, stefan_AT_space.twc.de (PGP!), Hamburg/Germany
> > KDE Developer, project infos at http://space.twc.de/~stefan/kde *-
>

-- 

Best regards,

Hannu ----- Hannu Savolainen (hannu_AT_opensound.com) http://www.opensound.com (Open Sound System (OSS)) http://www.compusonic.fi (Finnish OSS pages)


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

This archive was generated by hypermail 2b28 : Fri Sep 08 2000 - 15:13:41 EEST