[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] various places: Include resampler delay to latency reports and calculations
PulseAudio Marge Bot (@pulseaudio-merge-bot)
gitlab at gitlab.freedesktop.org
Sat May 28 14:34:36 UTC 2022
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
2af10cf3 by Georg Chini at 2022-05-28T14:30:59+00:00
various places: Include resampler delay to latency reports and calculations
The resampler delay was not taken into account in all necessary places.
This patch adds it where required.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/708>
- - - - -
9 changed files:
- src/modules/echo-cancel/module-echo-cancel.c
- src/modules/module-combine-sink.c
- src/modules/module-equalizer-sink.c
- src/modules/module-ladspa-sink.c
- src/modules/module-remap-sink.c
- src/modules/module-virtual-sink.c
- src/modules/module-virtual-surround-sink.c
- src/modules/rtp/module-rtp-recv.c
- src/pulsecore/protocol-native.c
Changes:
=====================================
src/modules/echo-cancel/module-echo-cancel.c
=====================================
@@ -460,6 +460,9 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
/* Add the latency internal to our sink input on top */
pa_bytes_to_usec(pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq), &u->sink_input->sink->sample_spec);
+ /* Add resampler delay */
+ *((int64_t*) data) += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
+
return 0;
}
@@ -1053,6 +1056,9 @@ static void source_output_snapshot_within_thread(struct userdata *u, struct snap
now = pa_rtclock_now();
latency = pa_source_get_latency_within_thread(u->source_output->source, false);
+ /* Add resampler delay */
+ latency += pa_resampler_get_delay_usec(u->source_output->thread_info.resampler);
+
delay = pa_memblockq_get_length(u->source_output->thread_info.delay_memblockq);
delay = (u->source_output->thread_info.resampler ? pa_resampler_request(u->source_output->thread_info.resampler, delay) : delay);
@@ -1132,6 +1138,9 @@ static int sink_input_process_msg_cb(pa_msgobject *obj, int code, void *data, in
now = pa_rtclock_now();
latency = pa_sink_get_latency_within_thread(u->sink_input->sink, false);
+ /* Add resampler delay */
+ latency += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
+
delay = pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq);
delay = (u->sink_input->thread_info.resampler ? pa_resampler_request(u->sink_input->thread_info.resampler, delay) : delay);
=====================================
src/modules/module-combine-sink.c
=====================================
@@ -771,6 +771,8 @@ static int sink_input_process_msg(pa_msgobject *obj, int code, void *data, int64
/* Add content of memblockq's to sink latency */
o->latency_snapshot.sink_latency = pa_sink_get_latency_within_thread(o->sink, true) +
pa_bytes_to_usec(length, &o->sink->sample_spec);
+ /* Add resampler latency */
+ o->latency_snapshot.sink_latency += pa_resampler_get_delay_usec(o->sink_input->thread_info.resampler);
o->latency_snapshot.timestamp = pa_rtclock_now();
=====================================
src/modules/module-equalizer-sink.c
=====================================
@@ -265,6 +265,9 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
pa_bytes_to_usec(pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq), &u->sink_input->sink->sample_spec);
// pa_bytes_to_usec(u->samples_gathered * fs, &u->sink->sample_spec);
//+ pa_bytes_to_usec(u->latency * fs, ss)
+
+ /* Add resampler latency */
+ *((int64_t*) data) += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
return 0;
}
}
=====================================
src/modules/module-ladspa-sink.c
=====================================
@@ -361,6 +361,9 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
/* Add the latency internal to our sink input on top */
pa_bytes_to_usec(pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq), &u->sink_input->sink->sample_spec);
+ /* Add resampler latency */
+ *((int64_t*) data) += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
+
return 0;
case LADSPA_SINK_MESSAGE_UPDATE_PARAMETERS:
=====================================
src/modules/module-remap-sink.c
=====================================
@@ -93,6 +93,9 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
/* Add the latency internal to our sink input on top */
pa_bytes_to_usec(pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq), &u->sink_input->sink->sample_spec);
+ /* Add resampler latency */
+ *((int64_t*) data) += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
+
return 0;
}
=====================================
src/modules/module-virtual-sink.c
=====================================
@@ -105,6 +105,9 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
/* Add the latency internal to our sink input on top */
pa_bytes_to_usec(pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq), &u->sink_input->sink->sample_spec);
+ /* Add resampler latency */
+ *((int64_t*) data) += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
+
return 0;
}
=====================================
src/modules/module-virtual-surround-sink.c
=====================================
@@ -280,6 +280,9 @@ static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t of
/* Add the latency internal to our sink input on top */
pa_bytes_to_usec(pa_memblockq_get_length(u->sink_input->thread_info.render_memblockq), &u->sink_input->sink->sample_spec);
+ /* Add resampler latency */
+ *((int64_t*) data) += pa_resampler_get_delay_usec(u->sink_input->thread_info.resampler);
+
return 0;
}
=====================================
src/modules/rtp/module-rtp-recv.c
=====================================
@@ -285,6 +285,7 @@ static int rtpoll_work_cb(pa_rtpoll_item *i) {
pa_log_debug("wi=%lu ri=%lu", (unsigned long) wi, (unsigned long) ri);
sink_delay = pa_sink_get_latency_within_thread(s->sink_input->sink, false);
+ sink_delay += pa_resampler_get_delay_usec(s->sink_input->thread_info.resampler);
render_delay = pa_bytes_to_usec(pa_memblockq_get_length(s->sink_input->thread_info.render_memblockq), &s->sink_input->sink->sample_spec);
if (ri > render_delay+sink_delay)
=====================================
src/pulsecore/protocol-native.c
=====================================
@@ -1422,6 +1422,8 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
s->write_index = pa_memblockq_get_write_index(s->memblockq);
s->render_memblockq_length = pa_memblockq_get_length(s->sink_input->thread_info.render_memblockq);
s->current_sink_latency = pa_sink_get_latency_within_thread(s->sink_input->sink, false);
+ /* Add resampler latency */
+ s->current_sink_latency += pa_resampler_get_delay_usec(i->thread_info.resampler);
s->underrun_for = s->sink_input->thread_info.underrun_for;
s->playing_for = s->sink_input->thread_info.playing_for;
@@ -1700,6 +1702,8 @@ static int source_output_process_msg(pa_msgobject *_o, int code, void *userdata,
/* Atomically get a snapshot of all timing parameters... */
s->current_monitor_latency = o->source->monitor_of ? pa_sink_get_latency_within_thread(o->source->monitor_of, false) : 0;
s->current_source_latency = pa_source_get_latency_within_thread(o->source, false);
+ /* Add resampler latency */
+ s->current_source_latency += pa_resampler_get_delay_usec(o->thread_info.resampler);
s->on_the_fly_snapshot = pa_atomic_load(&s->on_the_fly);
return 0;
}
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/2af10cf39b1a12fb000672462ddaaf37f7d6e25e
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/2af10cf39b1a12fb000672462ddaaf37f7d6e25e
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20220528/54359783/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list