[PATCH] dmix: fix inconsistent status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux