All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannu Savolainen <hannu@opensound.com>
To: rahul.iyer@ymail.com
Cc: Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org, Alexandre Ratchov <alex@caoua.org>
Subject: Re: ALSA OSS Emulation - Read - EAGAIN Errors
Date: Sat, 09 Aug 2008 09:41:42 +0300	[thread overview]
Message-ID: <489D3C26.8070003@opensound.com> (raw)
In-Reply-To: <640255.10395.qm@web59603.mail.ac4.yahoo.com>

Rahul Iyer wrote:
> Hi Takashi and Alexandre
>
> Thank you for your attention and previous replies.
>
> I understand EAGAIN errors can be ignored as trivial, but given there are so many of them (600 EAGAIN errors on an average for each successful call) indicates an inherent issue. And I believe it was singularly causing poor voice quality and high cpu usage.
>   
Application should wait some time after EAGAIN before calling read/write 
again. Otherwise it will spend all the available CPU time in the system 
(one core).

In addition the application should check how many bytes actually got 
written since write() may take only the first few bytes that fit in the 
buffer. The remaining bytes need to be stored by the application until 
it becomes possible to write it. Most applications that use O_NONBLOCK 
fail to do this which will cause badly garbled sound.


IMHO use of non-blocking I/O should be banned. It has absolutely no use. 
It's far far far too difficult to use even for senior programers. 
Typical "legacy" OSS applications just turn on O_NONBLOCK and then don't 
do any error checking.  However the application will work just fine if 
O_NONBLOCK is removed from the sources. In fact OSS4 has a blacklist 
feature to turn O_NONBLOCK silently off in certain popular applications 
because they don't use the feature properly.

Use of poll/select is the only proper way to avoid blocking. In fact 
trying to avoid blocking is completely unnecessary since audio 
reads/writes will never block longer than few millisecods at time 
(provided that the app uses relatively short reads/writes).

Best regards,

Hannu

      reply	other threads:[~2008-08-09  6:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-30 15:20 ALSA OSS Emulation - Read - EAGAIN Errors Rahul Iyer
2008-07-31 10:04 ` Takashi Iwai
2008-08-09  2:18   ` Rahul Iyer
2008-08-09  6:41     ` Hannu Savolainen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=489D3C26.8070003@opensound.com \
    --to=hannu@opensound.com \
    --cc=alex@caoua.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=rahul.iyer@ymail.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.