loopback: Change adjust_time parameter to double to allow adjust times below 1s

The adjust_time parameter is changed to double to allow better granularity
and adjust times below 1s. This may be useful for a better latency control,
although with alsa devices and the current smoother code no significant
improvement could be found for values below 500ms.
This patch also changes the default adjust time to 1s, the old value of 10s
does not allow a tight control of the end to end latency and would lead to
unnecessary jitter.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/56>
This commit is contained in:
Georg Chini 2020-01-27 20:31:44 +01:00
parent dd18b06321
commit 0f91b2146d

View file

@ -68,7 +68,7 @@ PA_MODULE_USAGE(
#define MIN_DEVICE_LATENCY (2.5*PA_USEC_PER_MSEC)
#define DEFAULT_ADJUST_TIME_USEC (10*PA_USEC_PER_SEC)
#define DEFAULT_ADJUST_TIME_USEC (1*PA_USEC_PER_SEC)
typedef struct loopback_msg loopback_msg;
@ -1552,7 +1552,7 @@ int pa__init(pa_module *m) {
bool rate_set = false;
bool channels_set = false;
pa_memchunk silence;
uint32_t adjust_time_sec;
double adjust_time_sec;
const char *n;
bool remix = true;
@ -1677,16 +1677,20 @@ int pa__init(pa_module *m) {
u->initial_adjust_pending = true;
adjust_time_sec = DEFAULT_ADJUST_TIME_USEC / PA_USEC_PER_SEC;
if (pa_modargs_get_value_u32(ma, "adjust_time", &adjust_time_sec) < 0) {
if (pa_modargs_get_value_double(ma, "adjust_time", &adjust_time_sec) < 0) {
pa_log("Failed to parse adjust_time value");
goto fail;
}
if (adjust_time_sec != DEFAULT_ADJUST_TIME_USEC / PA_USEC_PER_SEC)
u->adjust_time = adjust_time_sec * PA_USEC_PER_SEC;
else
u->adjust_time = DEFAULT_ADJUST_TIME_USEC;
/* Allow values >= 0.1 and also 0 which means no adjustment */
if (adjust_time_sec < 0.1) {
if (adjust_time_sec < 0 || adjust_time_sec > 0) {
pa_log("Failed to parse adjust_time value");
goto fail;
}
}
u->adjust_time = adjust_time_sec * PA_USEC_PER_SEC;
u->real_adjust_time = u->adjust_time;
pa_source_output_new_data_init(&source_output_data);