summaryrefslogtreecommitdiff
path: root/src/modules/module-solaris.c
diff options
context:
space:
mode:
authorGeorg Chini <georg@chini.tk>2017-04-17 19:50:10 +0200
committerGeorg Chini <georg@chini.tk>2017-04-17 19:50:10 +0200
commitfe70b9e11aa0312f5d9508158c6cd652f66d732d (patch)
tree0331273dbd99deaa37facf5ea8e34f9aabc356fb /src/modules/module-solaris.c
parenta5fccd4645729c06db2caccb67149f2e07598300 (diff)
source/sink: Allow pa_{source, sink}_get_latency_within_thread() to return negative values
The reported latency of source or sink is based on measured initial conditions. If the conditions contain an error, the estimated latency values may become negative. This does not indicate that the latency is indeed negative but can be considered merely an offset error. The current get_latency_in_thread() calls and the implementations of the PA_{SINK,SOURCE}_MESSAGE_GET_LATENCY messages truncate negative latencies because they do not make sense from a physical point of view. In fact, the values are truncated twice, once in the message handler and a second time in the pa_{source,sink}_get_latency_within_thread() call itself. This leads to two problems for the latency controller within module-loopback: - Truncating leads to discontinuities in the latency reports which then trigger unwanted end to end latency corrections. - If a large negative port latency offsets is set, the reported latency is always 0, making it impossible to control the end to end latency at all. This patch is a pre-condition for solving these problems. It adds a new flag to pa_{sink,source}_get_latency_within_thread() to allow negative return values. Truncating is also removed in all implementations of the PA_{SINK,SOURCE}_MESSAGE_GET_LATENCY message handlers. The allow_negative flag is set to false for all calls of pa_{sink,source}_get_latency_within_thread() except when used within PA_{SINK,SOURCE}_MESSAGE_GET_LATENCY. This means that the original behavior is not altered in most cases. Only if a positive latency offset is set and the message returns a negative value, the reported latency is smaller because the values are not truncated twice. Additionally let PA_SOURCE_MESSAGE_GET_LATENCY return -pa_sink_get_latency_within_thread() for monitor sources because the source gets the data before it is played.
Diffstat (limited to 'src/modules/module-solaris.c')
-rw-r--r--src/modules/module-solaris.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index ccff69fc9..fee69e747 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -385,7 +385,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
switch (code) {
case PA_SINK_MESSAGE_GET_LATENCY:
- *((pa_usec_t*) data) = sink_get_latency(u, &PA_SINK(o)->sample_spec);
+ *((int64_t*) data) = sink_get_latency(u, &PA_SINK(o)->sample_spec);
return 0;
case PA_SINK_MESSAGE_SET_STATE: