All of lore.kernel.org
 help / color / mirror / Atom feed
* ALSA: dmix: pcm status incomplete
@ 2015-05-06  4:29 Dan Hordern
  2015-05-20  6:47 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Hordern @ 2015-05-06  4:29 UTC (permalink / raw)
  To: alsa-devel

I require timestamp information from the soundcard and host for our
application. However, I noticed that when using "dmix:0,0" instead of
"hw:0,0", the audio timestamp and delay frames are both zero.

Looking in to the code, it seems that the 'snd_pcm_dmix_status' function
does not populate either of these. In order to expose these, I have
modified this function to get this information from the slave pcm; patch
below.

I was hoping for some feedback on this change. I am not sure if the delay
value makes sense as yet, and whether there are consequences of using the
hardware trigger timestamp etc. I am guessing the dsnoop and dshare plugins
may also have this issue, though I have not checked.

Thanks,
Dan


diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
index babde6a..a4d7fc0 100644
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -475,12 +475,12 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm,
snd_pcm_status_t * status)
                break;
        }
        memset(status, 0, sizeof(*status));
+       snd_pcm_status(dmix->spcm, status);
        status->state = snd_pcm_dmix_state(pcm);
-       status->trigger_tstamp = dmix->trigger_tstamp;
-       gettimestamp(&status->tstamp, pcm->tstamp_type);
        status->avail = snd_pcm_mmap_playback_avail(pcm);
        status->avail_max = status->avail > dmix->avail_max ? status->avail
: dmix->avail_max;
        dmix->avail_max = 0;
+       status->delay = snd_pcm_mmap_playback_delay(pcm);
        return 0;
 }

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

* Re: ALSA: dmix: pcm status incomplete
  2015-05-06  4:29 ALSA: dmix: pcm status incomplete Dan Hordern
@ 2015-05-20  6:47 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2015-05-20  6:47 UTC (permalink / raw)
  To: Dan Hordern; +Cc: alsa-devel

At Wed, 6 May 2015 14:29:01 +1000,
Dan Hordern wrote:
> 
> I require timestamp information from the soundcard and host for our
> application. However, I noticed that when using "dmix:0,0" instead of
> "hw:0,0", the audio timestamp and delay frames are both zero.
> 
> Looking in to the code, it seems that the 'snd_pcm_dmix_status' function
> does not populate either of these. In order to expose these, I have
> modified this function to get this information from the slave pcm; patch
> below.
> 
> I was hoping for some feedback on this change. I am not sure if the delay
> value makes sense as yet, and whether there are consequences of using the
> hardware trigger timestamp etc. I am guessing the dsnoop and dshare plugins
> may also have this issue, though I have not checked.

The trigger_tstamp needs to be kept because you can't fetch it from
the slave PCM.  (Imagine multiple dmix streams are triggered at
different times on the same slave PCM.)

For the delay value, I think your code is OK.

And yes, please fix dsnoop and dshare similarly, too.

Could you resubmit the patch with the fixes above?


Thanks!

Takashi
> 
> Thanks,
> Dan
> 
> 
> diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
> index babde6a..a4d7fc0 100644
> --- a/src/pcm/pcm_dmix.c
> +++ b/src/pcm/pcm_dmix.c
> @@ -475,12 +475,12 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm,
> snd_pcm_status_t * status)
>                 break;
>         }
>         memset(status, 0, sizeof(*status));
> +       snd_pcm_status(dmix->spcm, status);
>         status->state = snd_pcm_dmix_state(pcm);
> -       status->trigger_tstamp = dmix->trigger_tstamp;
> -       gettimestamp(&status->tstamp, pcm->tstamp_type);
>         status->avail = snd_pcm_mmap_playback_avail(pcm);
>         status->avail_max = status->avail > dmix->avail_max ? status->avail
> : dmix->avail_max;
>         dmix->avail_max = 0;
> +       status->delay = snd_pcm_mmap_playback_delay(pcm);
>         return 0;
>  }
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

end of thread, other threads:[~2015-05-20  6:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06  4:29 ALSA: dmix: pcm status incomplete Dan Hordern
2015-05-20  6:47 ` 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.