All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] ALSA: core: do not update tstamp when hw ptr has not moved
@ 2017-11-16 12:43 Henrik Eriksson
  2017-11-16 14:48 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Henrik Eriksson @ 2017-11-16 12:43 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel; +Cc: Pierre-Louis Bossart

Hello

This reverts a change that was part of a larger commit.  That change
broke timestamps in some application code for us as outlined in the log,
and reverting it obviously fixes this.  Since the original change did
not explain why the behaviour was modified I can't speak for the effects
on that use case.

Regards,
/henrik
>8------------------------------------------------------8<
Commit 3179f62001880e588e229db3006a59ad87b7792a ("ALSA: core: add
.get_time_info") made an undocumented change to the behaviour of the
PCM runtime tstamp.  Prior to this change the tstamp was not updated
by snd_pcm_update_hw_ptr0() unless the hw ptr had moved, after this
change the tstamp is always updated.

For an application, using alsa-lib, doing snd_pcm_readi() followed by
snd_pcm_status() to estimate the age of the read samples by subtracting
status->avail * [sample rate] from status->tstamp this change degraded
the accuracy of that estimate on devices where the pcm hw does not
provide a granular hw pointer.  On a device using
soc-generic-dmaengine-pcm.c and a dma-engine with residue_granularity
DMA_RESIDUE_GRANULARITY_DESCRIPTOR the accuracy of the estimate depended
on the latency between the PCM hw completing a period and when the
driver called snd_pcm_period_elapsed() to notify ALSA core, typically
determined by interrupt handling latency.  After this change the
accuracy of the estimate is determined by the latency between the PCM hw
completing a period and the application calling snd_pcm_status(),
determined by the scheduling of the application process.

Revert the part of commit 3179f62001880e588e229db3006a59ad87b7792a
("ALSA: core: add .get_time_info") that changed be behaviour of
snd_pcm_update_hw_ptr0() when the PCM hw pointer has not moved.

Fixes: 3179f6200188 ("ALSA: core: add .get_time_info")
Signed-off-by: Henrik Eriksson <henrik.eriksson@axis.com>
---
 sound/core/pcm_lib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index a93a4235a332..2fbaf9a974cc 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -437,10 +437,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 	}
 
  no_delta_check:
-	if (runtime->status->hw_ptr == new_hw_ptr) {
-		update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
+	if (runtime->status->hw_ptr == new_hw_ptr)
 		return 0;
-	}
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
 	    runtime->silence_size > 0)
-- 
2.11.0


-- 
henrik eriksson
fixed box cameras firmware, base video products, axis communications ab

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

end of thread, other threads:[~2017-11-20 13:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-16 12:43 [RFC PATCH] ALSA: core: do not update tstamp when hw ptr has not moved Henrik Eriksson
2017-11-16 14:48 ` Takashi Iwai
2017-11-16 18:11   ` Pierre-Louis Bossart
2017-11-16 18:49     ` Takashi Iwai
2017-11-17  8:34       ` Henrik Eriksson
2017-11-20 13:13       ` Henrik Eriksson
2017-11-20 13:29         ` 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.