Skip to content

Instantly share code, notes, and snippets.

@dasl-
Created November 12, 2022 03:50
Show Gist options
  • Save dasl-/7e09877818c7e15f39395340af846f6a to your computer and use it in GitHub Desktop.
Save dasl-/7e09877818c7e15f39395340af846f6a to your computer and use it in GitHub Desktop.
diff --git a/audio_alsa.c b/audio_alsa.c
index 62db843f..9cb824a1 100644
--- a/audio_alsa.c
+++ b/audio_alsa.c
@@ -1450,6 +1450,7 @@ static int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *
state_temp = snd_pcm_state(alsa_handle);
if ((state_temp == SND_PCM_STATE_RUNNING) || (state_temp == SND_PCM_STATE_DRAINING)) {
ret = snd_pcm_delay(alsa_handle, &delay_temp);
+ debug(2, "the delay is %" PRId64 " frames", delay_temp);
} else {
// not running, thus no delay information, thus can't check for frame
// rates
@@ -1889,6 +1890,12 @@ static int play(void *buf, int samples, __attribute__((unused)) int sample_type,
__attribute__((unused)) uint32_t timestamp,
__attribute__((unused)) uint64_t playtime) {
+ if (sample_type == play_samples_are_timed) {
+ int64_t lead_time = playtime - get_absolute_time_in_ns();
+ debug(2, "leadtime for frame %u is %" PRId64 " nanoseconds, i.e. %f seconds. Playtime: %" PRId64, timestamp,
+ lead_time, 0.000000001 * lead_time, playtime);
+ }
+
// play() will change the state of the alsa_backend_mode to abm_playing
// also, if the present alsa_backend_state is abm_disconnected, then first the
// DAC must be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment