alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Max Kellermann <max@duempel.org>
To: alsa-devel@alsa-project.org
Subject: dmix, snd_pcm_drain(), SND_PCM_NONBLOCK - bug?
Date: Thu, 16 Mar 2017 13:23:36 +0100	[thread overview]
Message-ID: <20170316122336.GA7038@swift.blarg.de> (raw)

Hi,

I have received a bug report for the Music Player Daemon which
complains about a freezing MPD process, after I switched MPD's ALSA
output to non-blocking mode:

 https://bugs.musicpd.org/view.php?id=4662

This happens when snd_pcm_drain() is used on a dmix PCM which is in
SND_PCM_NONBLOCK mode.  snd_pcm_drain() will be called repeatedly,
because ALSA's file descriptor is always ready.

According to my research, the bug is in __snd_pcm_dmix_drain().  This
function always returns -EAGAIN when SND_PCM_NONBLOCK is set:

  if (pcm->mode & SND_PCM_NONBLOCK)
        return -EAGAIN;

This comes very early in the function, before any other relevant
checks.  It can never finish that way, and calling it again at any
time will never do anything.  Thus, snd_pcm_drain() appears to be
broken in non-blocking mode.

Or am I misunderstanding how snd_pcm_drain() is supposed to be used in
non-blocking mode?

Max

             reply	other threads:[~2017-03-16 12:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 12:23 Max Kellermann [this message]
2017-03-20  7:38 ` dmix, snd_pcm_drain(), SND_PCM_NONBLOCK - bug? Takashi Iwai
2017-03-29 17:59   ` Max Kellermann
2017-03-20  7:39 ` Jaroslav Kysela
2017-03-20  7:44   ` Jaroslav Kysela

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=20170316122336.GA7038@swift.blarg.de \
    --to=max@duempel.org \
    --cc=alsa-devel@alsa-project.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).