All of lore.kernel.org
 help / color / mirror / Atom feed
* OSS SNDCTL_DSP_GETISPACE, non-blocking read: messy :-\
@ 2003-10-25 20:02 Andreas Mohr
  2003-10-27 12:01 ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Mohr @ 2003-10-25 20:02 UTC (permalink / raw)
  To: alsa-devel; +Cc: Jaroslav Kysela

Hi all,

RAT (Robust Audio Tool, http://www-mice.cs.ucl.ac.uk/multimedia/software/rat/)
shows quite miserable behaviour on ALSA/OSS (current CVS):

andi@note:/home/andi$ rat 193.8.230.138/2074
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
audio_read: Resource temporarily unavailable
.
.
.
andi@note:/home/andi$

I've been analyzing the reason for about 1.5 hours now,
and I guess I know what the problem is, but I'm uncertain as to how it should
be fixed (I could probably fix it, but I REALLY want to leave it to much more
experienced people since I'm afraid that code is VERY easy to break...).

Our SNDCTL_DSP_GETISPACE implementation in alsa-driver/acore/oss/pcm_oss.c
calls snd_pcm_oss_get_space(), which returns the number of bytes available
to read (e.g. 224).

RAT then does a read() with exactly this amount of bytes.

The read() causes alsa-kernel/core/oss/pcm_oss.c/snd_pcm_oss_read()
to be called, with this amount of bytes passed.

This now calls snd_pcm_oss_read1(), with the bytes set to the same amount
again.

For some stupid reason, _read1() now ALWAYS calls into snd_pcm_oss_read2()
with an amount of runtime->oss.period_bytes bytes to be read, which happens
to be 256.

With a blocking read, this would probably be no problem, since we just wait
until we have enough data in the buffer, however with a non-blocking read,
snd_pcm_lib_read(), which gets called by snd_pcm_oss_read3() that's being
called by snd_pcm_oss_read2(), simply returns -EAGAIN since it cannot handle
the much too large request.


Or, as a short summary:
The application is perfectly well aware of how many bytes there are left
to read (from calling SNDCTL_DSP_GETISPACE) and then does a read() with
this amount of bytes, however since the ALSA OSS layer attempts to read
this byte amount in blocks of runtime->oss.period_bytes bytes from the sound
device, we ARTIFICIALLY cause a -EAGAIN to be returned due to insufficient
available data, thus potentially confusing many OSS applications.

Now what to do here?

Thanks!

Andreas Mohr


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-10-28 14:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-25 20:02 OSS SNDCTL_DSP_GETISPACE, non-blocking read: messy :-\ Andreas Mohr
2003-10-27 12:01 ` Takashi Iwai
2003-10-27 12:11   ` Andreas Mohr
2003-10-28 11:21     ` Takashi Iwai
2003-10-28 12:36       ` Jaroslav Kysela
2003-10-28 13:24         ` Takashi Iwai
2003-10-28 13:30         ` Jaroslav Kysela
2003-10-28 14:27           ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.