stream: add more timing info

Keep track of queued data in the stream
Pass delay field around to make it possible to know about the raw
software read/write pointer and the hardware one.
Start stream position at 0
This commit is contained in:
Wim Taymans 2018-07-19 13:30:27 +02:00
parent d3c203b744
commit 0d148654c0
8 changed files with 72 additions and 21 deletions

View file

@ -36,6 +36,7 @@ static int spa_alsa_open(struct state *state)
state->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
state->opened = true;
state->sample_count = 0;
return 0;
}
@ -565,7 +566,8 @@ static void alsa_on_playback_timeout_event(struct spa_source *source)
if (state->clock) {
state->clock->nsec = SPA_TIMESPEC_TO_TIME(&state->now);
state->clock->rate = SPA_FRACTION(state->rate, 1);
state->clock->position = state->sample_count - state->filled;
state->clock->position = state->sample_count;
state->clock->delay = state->filled;
}
spa_log_trace(state->log, "timeout %ld %d %ld %ld %ld", state->filled, state->threshold,
@ -636,7 +638,8 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
if (state->clock) {
state->clock->nsec = SPA_TIMESPEC_TO_TIME(&state->now);
state->clock->rate = SPA_FRACTION(state->rate, 1);
state->clock->position = state->sample_count + avail;
state->clock->position = state->sample_count;
state->clock->delay = avail;
}
spa_log_trace(state->log, "timeout %ld %d %ld %ld %ld %ld %ld", avail, state->threshold,