mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
latency: handle negative latency correctly
In our current world, it is possible to have a negative delay. This means that the stream should be delayed to sync with other streams. The pulse-server sets negative delay and the Latency message can hold those negative values so make sure we handle them in the helper functions as well. Do the delay calculations in pw_stream and JACK with signed values to correctly handle negative values. Clamp JACK latency range to 0 because negative latency is not supported in JACK. We should also probably make sure we never end up with negative latency, mostly in ALSA when we set a Latency offset, but that is another detail.
This commit is contained in:
parent
9243ed0cbd
commit
da86026b7a
5 changed files with 40 additions and 20 deletions
|
|
@ -38,21 +38,27 @@ spa_latency_info_combine_start(struct spa_latency_info *info, enum spa_direction
|
|||
{
|
||||
*info = SPA_LATENCY_INFO(direction,
|
||||
.min_quantum = FLT_MAX,
|
||||
.max_quantum = 0.0f,
|
||||
.min_rate = UINT32_MAX,
|
||||
.max_rate = 0,
|
||||
.min_ns = UINT64_MAX,
|
||||
.max_ns = 0);
|
||||
.max_quantum = FLT_MIN,
|
||||
.min_rate = INT32_MAX,
|
||||
.max_rate = INT32_MIN,
|
||||
.min_ns = INT64_MAX,
|
||||
.max_ns = INT64_MIN);
|
||||
}
|
||||
static inline void
|
||||
spa_latency_info_combine_finish(struct spa_latency_info *info)
|
||||
{
|
||||
if (info->min_quantum == FLT_MAX)
|
||||
info->min_quantum = 0;
|
||||
if (info->min_rate == UINT32_MAX)
|
||||
if (info->max_quantum == FLT_MIN)
|
||||
info->max_quantum = 0;
|
||||
if (info->min_rate == INT32_MAX)
|
||||
info->min_rate = 0;
|
||||
if (info->min_ns == UINT64_MAX)
|
||||
if (info->max_rate == INT32_MIN)
|
||||
info->max_rate = 0;
|
||||
if (info->min_ns == INT64_MAX)
|
||||
info->min_ns = 0;
|
||||
if (info->max_ns == INT64_MIN)
|
||||
info->max_ns = 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ struct spa_latency_info {
|
|||
enum spa_direction direction;
|
||||
float min_quantum;
|
||||
float max_quantum;
|
||||
uint32_t min_rate;
|
||||
uint32_t max_rate;
|
||||
uint64_t min_ns;
|
||||
uint64_t max_ns;
|
||||
int32_t min_rate;
|
||||
int32_t max_rate;
|
||||
int64_t min_ns;
|
||||
int64_t max_ns;
|
||||
};
|
||||
|
||||
#define SPA_LATENCY_INFO(dir,...) ((struct spa_latency_info) { .direction = (dir), ## __VA_ARGS__ })
|
||||
|
|
@ -74,8 +74,8 @@ enum spa_param_process_latency {
|
|||
/** Helper structure for managing process latency objects */
|
||||
struct spa_process_latency_info {
|
||||
float quantum;
|
||||
uint32_t rate;
|
||||
uint64_t ns;
|
||||
int32_t rate;
|
||||
int64_t ns;
|
||||
};
|
||||
|
||||
#define SPA_PROCESS_LATENCY_INFO_INIT(...) ((struct spa_process_latency_info) { __VA_ARGS__ })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue