mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
stream: fix read and write index for capture
This commit is contained in:
parent
6eb6e31beb
commit
f73d640cb8
1 changed files with 13 additions and 6 deletions
19
src/stream.c
19
src/stream.c
|
|
@ -336,6 +336,7 @@ static void update_timing_info(pa_stream *s)
|
||||||
struct pw_time pwt;
|
struct pw_time pwt;
|
||||||
pa_timing_info *ti = &s->timing_info;
|
pa_timing_info *ti = &s->timing_info;
|
||||||
size_t stride = pa_frame_size(&s->sample_spec);
|
size_t stride = pa_frame_size(&s->sample_spec);
|
||||||
|
uint64_t delay;
|
||||||
|
|
||||||
pw_stream_get_time(s->stream, &pwt);
|
pw_stream_get_time(s->stream, &pwt);
|
||||||
s->timing_info_valid = false;
|
s->timing_info_valid = false;
|
||||||
|
|
@ -345,16 +346,22 @@ static void update_timing_info(pa_stream *s)
|
||||||
|
|
||||||
pa_timeval_store(&ti->timestamp, pwt.now / SPA_NSEC_PER_USEC);
|
pa_timeval_store(&ti->timestamp, pwt.now / SPA_NSEC_PER_USEC);
|
||||||
ti->synchronized_clocks = true;
|
ti->synchronized_clocks = true;
|
||||||
if (s->direction == PA_STREAM_PLAYBACK)
|
|
||||||
ti->sink_usec = (-pwt.delay * SPA_USEC_PER_SEC / pwt.rate.num);
|
|
||||||
else
|
|
||||||
ti->source_usec = (pwt.delay * SPA_USEC_PER_SEC / pwt.rate.num);
|
|
||||||
ti->transport_usec = 0;
|
ti->transport_usec = 0;
|
||||||
ti->playing = 1;
|
ti->playing = 1;
|
||||||
ti->write_index_corrupt = false;
|
ti->write_index_corrupt = false;
|
||||||
ti->write_index = pwt.queued + (pwt.ticks * s->sample_spec.rate / pwt.rate.num) * stride;
|
|
||||||
ti->read_index_corrupt = false;
|
ti->read_index_corrupt = false;
|
||||||
ti->read_index = ((pwt.ticks + pwt.delay) * s->sample_spec.rate / pwt.rate.num) * stride;
|
|
||||||
|
delay = pwt.delay * SPA_USEC_PER_SEC / pwt.rate.num;
|
||||||
|
if (s->direction == PA_STREAM_PLAYBACK) {
|
||||||
|
ti->sink_usec = delay;
|
||||||
|
ti->write_index = pwt.queued + (pwt.ticks * s->sample_spec.rate / pwt.rate.num) * stride;
|
||||||
|
ti->read_index = ((pwt.ticks - pwt.delay) * s->sample_spec.rate / pwt.rate.num) * stride;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ti->source_usec = delay;
|
||||||
|
ti->read_index = pwt.queued + (pwt.ticks * s->sample_spec.rate / pwt.rate.num) * stride;
|
||||||
|
ti->write_index = ((pwt.ticks + pwt.delay) * s->sample_spec.rate / pwt.rate.num) * stride;
|
||||||
|
}
|
||||||
|
|
||||||
ti->configured_sink_usec = 0;
|
ti->configured_sink_usec = 0;
|
||||||
ti->configured_source_usec = 0;
|
ti->configured_source_usec = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue