mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Revert "alsa: also use interpolated time as nsec in IRQ mode"
This reverts commit 49cdb468c2.
We should not do this, the nsec field should be relatable to the clock
monotonic time. If we use the estimated time, without actually using it
as a timer, we might end up with a wakeup time in the future compared to
the MONOTONIC clock time.
Instead, you can use the estimated current time simply by subtracting
the rate corrected duration from the next_nsec. This is really only
useful for some selected use cases (like in the JACK library).
This fixes some issues where in pro-audio mode, a client would try to
compare the current MONOTONIC time to nsec and find that it is in the
past.
This commit was done in an attempt to fix #3657 but it turned out the
real problem was something else.
This commit is contained in:
parent
74f48a2bec
commit
5980f6988a
1 changed files with 13 additions and 19 deletions
|
|
@ -2532,15 +2532,6 @@ static int get_status(struct state *state, uint64_t current_time, snd_pcm_uframe
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static uint64_t get_time_ns(struct state *state)
|
||||
{
|
||||
struct timespec now;
|
||||
if (spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now) < 0)
|
||||
return 0;
|
||||
return SPA_TIMESPEC_TO_NSEC(&now);
|
||||
}
|
||||
|
||||
static int update_time(struct state *state, uint64_t current_time, snd_pcm_sframes_t delay,
|
||||
snd_pcm_sframes_t target, bool follower)
|
||||
{
|
||||
|
|
@ -2548,15 +2539,8 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram
|
|||
int32_t diff;
|
||||
|
||||
if (state->disable_tsched && !follower) {
|
||||
uint64_t now = get_time_ns(state);
|
||||
|
||||
if (SPA_UNLIKELY(state->dll.bw == 0.0)) {
|
||||
current_time = now;
|
||||
err = 0.0;
|
||||
} else {
|
||||
err = (int64_t)(now - current_time);
|
||||
err = err / 1e9 * state->rate;
|
||||
}
|
||||
err = (int64_t)(current_time - state->next_time);
|
||||
err = err / 1e9 * state->rate;
|
||||
} else {
|
||||
if (state->stream == SND_PCM_STREAM_PLAYBACK)
|
||||
err = delay - target;
|
||||
|
|
@ -3183,6 +3167,14 @@ static int capture_ready(struct state *state)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t get_time_ns(struct state *state)
|
||||
{
|
||||
struct timespec now;
|
||||
if (spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now) < 0)
|
||||
return 0;
|
||||
return SPA_TIMESPEC_TO_NSEC(&now);
|
||||
}
|
||||
|
||||
static void alsa_wakeup_event(struct spa_source *source)
|
||||
{
|
||||
struct state *state = source->data, *follower;
|
||||
|
|
@ -3194,6 +3186,8 @@ static void alsa_wakeup_event(struct spa_source *source)
|
|||
int err;
|
||||
unsigned short revents;
|
||||
|
||||
current_time = get_time_ns(state);
|
||||
|
||||
for (int i = 0; i < state->n_fds; i++) {
|
||||
state->pfds[i].revents = state->source[i].rmask;
|
||||
/* Reset so that we only handle all our sources' events once */
|
||||
|
|
@ -3229,8 +3223,8 @@ static void alsa_wakeup_event(struct spa_source *source)
|
|||
return;
|
||||
}
|
||||
}
|
||||
current_time = state->next_time;
|
||||
}
|
||||
current_time = state->next_time;
|
||||
|
||||
/* first do all the sync */
|
||||
if (state->stream == SND_PCM_STREAM_CAPTURE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue