Commit 8c121586 authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] PCM interface - rename SNDRV_PCM_TSTAMP_MMAP to SNDRV_PCM_TSTAMP_ENABLE

Change semantics for SNDRV_PCM_TSTAMP_MMAP. Doing timestamping only in
the interrupt handler might cause that hw_ptr is not related to actual
timestamp. With this change, grab timestamp at every hw_ptr update to
have always valid timestamp + ring buffer position pair.
With this change, SNDRV_PCM_TSTAMP_MMAP was renamed to
SNDRV_PCM_TSTAMP_ENABLE. It's no regression (I think).
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent a64135a2
...@@ -354,8 +354,8 @@ struct snd_pcm_hw_params { ...@@ -354,8 +354,8 @@ struct snd_pcm_hw_params {
enum { enum {
SNDRV_PCM_TSTAMP_NONE = 0, SNDRV_PCM_TSTAMP_NONE = 0,
SNDRV_PCM_TSTAMP_MMAP, SNDRV_PCM_TSTAMP_ENABLE,
SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_MMAP, SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE,
}; };
struct snd_pcm_sw_params { struct snd_pcm_sw_params {
......
...@@ -227,7 +227,7 @@ static char *snd_pcm_subformat_names[] = { ...@@ -227,7 +227,7 @@ static char *snd_pcm_subformat_names[] = {
static char *snd_pcm_tstamp_mode_names[] = { static char *snd_pcm_tstamp_mode_names[] = {
TSTAMP(NONE), TSTAMP(NONE),
TSTAMP(MMAP), TSTAMP(ENABLE),
}; };
static const char *snd_pcm_stream_name(int stream) static const char *snd_pcm_stream_name(int stream)
......
...@@ -144,6 +144,8 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(struct snd_pcm_substre ...@@ -144,6 +144,8 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(struct snd_pcm_substre
{ {
snd_pcm_uframes_t pos; snd_pcm_uframes_t pos;
if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE)
snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp);
pos = substream->ops->pointer(substream); pos = substream->ops->pointer(substream);
if (pos == SNDRV_PCM_POS_XRUN) if (pos == SNDRV_PCM_POS_XRUN)
return pos; /* XRUN */ return pos; /* XRUN */
...@@ -186,8 +188,6 @@ static inline int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *subs ...@@ -186,8 +188,6 @@ static inline int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *subs
snd_pcm_uframes_t new_hw_ptr, hw_ptr_interrupt; snd_pcm_uframes_t new_hw_ptr, hw_ptr_interrupt;
snd_pcm_sframes_t delta; snd_pcm_sframes_t delta;
if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_MMAP)
snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp);
pos = snd_pcm_update_hw_ptr_pos(substream, runtime); pos = snd_pcm_update_hw_ptr_pos(substream, runtime);
if (pos == SNDRV_PCM_POS_XRUN) { if (pos == SNDRV_PCM_POS_XRUN) {
xrun(substream); xrun(substream);
......
...@@ -580,9 +580,15 @@ int snd_pcm_status(struct snd_pcm_substream *substream, ...@@ -580,9 +580,15 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
if (status->state == SNDRV_PCM_STATE_OPEN) if (status->state == SNDRV_PCM_STATE_OPEN)
goto _end; goto _end;
status->trigger_tstamp = runtime->trigger_tstamp; status->trigger_tstamp = runtime->trigger_tstamp;
if (snd_pcm_running(substream)) if (snd_pcm_running(substream)) {
snd_pcm_update_hw_ptr(substream); snd_pcm_update_hw_ptr(substream);
if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
status->tstamp = runtime->status->tstamp;
goto _tstamp_end;
}
}
snd_pcm_gettime(runtime, &status->tstamp); snd_pcm_gettime(runtime, &status->tstamp);
_tstamp_end:
status->appl_ptr = runtime->control->appl_ptr; status->appl_ptr = runtime->control->appl_ptr;
status->hw_ptr = runtime->status->hw_ptr; status->hw_ptr = runtime->status->hw_ptr;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment