All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cheng Sun <chengsun9@gmail.com>
To: alsa-devel@alsa-project.org
Subject: [PATCH] dmix: fix inconsistent status
Date: Fri, 26 May 2017 10:45:53 +0100	[thread overview]
Message-ID: <CAG6t6sN1HiGd0CrzuzqSYU3sgn-f_DWdtCLen_g8g4OPzgxMrg@mail.gmail.com> (raw)

Hi all,

Following on from my previous email with subject "1.1.3 bug report:
dmix reports inconsistent status", this is a preliminary patch which
fixes the issue.

Comments are welcome. In particular note that I'm not very familiar
with this code, and in particular I still don't quite understand what
the original commit which introduced this bug (38a2d2e) is meant to be
doing.

Note also that if this patch is committable, based on the commit
comment for 38a2d2e I think there might be an analogous change to be
made to faf53c1.

Cheers,
Cheng


---
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -459,12 +459,9 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
  *  plugin implementation
  */

-static snd_pcm_state_t snd_pcm_dmix_state(snd_pcm_t *pcm)
+static snd_pcm_state_t
snd_pcm_dmix_state_from_slave_state(snd_pcm_direct_t *dmix, snd_pcm_t
*pcm, snd_pcm_state_t state)
 {
-    snd_pcm_direct_t *dmix = pcm->private_data;
     int err;
-    snd_pcm_state_t state;
-    state = snd_pcm_state(dmix->spcm);
     switch (state) {
     case SND_PCM_STATE_SUSPENDED:
     case SND_PCM_STATE_DISCONNECTED:
@@ -483,6 +480,13 @@ static snd_pcm_state_t snd_pcm_dmix_state(snd_pcm_t *pcm)
     return dmix->state;
 }

+static snd_pcm_state_t snd_pcm_dmix_state(snd_pcm_t *pcm)
+{
+    snd_pcm_direct_t *dmix = pcm->private_data;
+    snd_pcm_state_t slave_state = snd_pcm_state(dmix->spcm);
+    return snd_pcm_dmix_state_from_slave_state(dmix, pcm, slave_state);
+}
+
 static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
 {
     snd_pcm_direct_t *dmix = pcm->private_data;
@@ -490,6 +494,8 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm,
snd_pcm_status_t * status)
     memset(status, 0, sizeof(*status));
     snd_pcm_status(dmix->spcm, status);

+    status->state = snd_pcm_dmix_state_from_slave_state(dmix, pcm,
status->state);
+
     switch (dmix->state) {
     case SNDRV_PCM_STATE_DRAINING:
     case SNDRV_PCM_STATE_RUNNING:

             reply	other threads:[~2017-05-26  9:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26  9:45 Cheng Sun [this message]
2017-05-30 15:33 ` [PATCH] dmix: fix inconsistent status Takashi Iwai
2017-05-31 10:49   ` Takashi Iwai

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=CAG6t6sN1HiGd0CrzuzqSYU3sgn-f_DWdtCLen_g8g4OPzgxMrg@mail.gmail.com \
    --to=chengsun9@gmail.com \
    --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 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.