mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
stream: add pw_stream_get_nsec() to get current time
Make a method to get the current time to compare agains the pw_time-now field. This is currently CLOCK_MONOTONIC but make this into a method so that we can more easily change it later.
This commit is contained in:
parent
81d8ecf0dc
commit
f4e391dd41
16 changed files with 53 additions and 58 deletions
|
|
@ -200,7 +200,6 @@ static int snd_pcm_pipewire_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delay
|
|||
snd_pcm_pipewire_t *pw = io->private_data;
|
||||
uintptr_t seq1, seq2;
|
||||
int64_t elapsed = 0, delay, now, avail;
|
||||
struct timespec ts;
|
||||
int64_t diff;
|
||||
|
||||
do {
|
||||
|
|
@ -218,8 +217,7 @@ static int snd_pcm_pipewire_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delay
|
|||
|
||||
if (now != 0 && (io->state == SND_PCM_STATE_RUNNING ||
|
||||
io->state == SND_PCM_STATE_DRAINING)) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
diff = SPA_TIMESPEC_TO_NSEC(&ts) - now;
|
||||
diff = pw_stream_get_nsec(pw->stream) - now;
|
||||
elapsed = (io->rate * diff) / SPA_NSEC_PER_SEC;
|
||||
|
||||
if (io->stream == SND_PCM_STREAM_PLAYBACK)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue