spa: add SPA_LATENCY_INFO_UNSET

Add a initializer for an unset latency info. Use this for combining
latency info.
This commit is contained in:
Wim Taymans 2025-06-12 12:12:28 +02:00
parent 5480a1382f
commit 2393be4543
2 changed files with 13 additions and 13 deletions

View file

@ -44,28 +44,24 @@ spa_latency_info_compare(const struct spa_latency_info *a, const struct spa_late
SPA_API_LATENCY_UTILS void
spa_latency_info_combine_start(struct spa_latency_info *info, enum spa_direction direction)
{
*info = SPA_LATENCY_INFO(direction,
.min_quantum = FLT_MAX,
.max_quantum = FLT_MIN,
.min_rate = INT32_MAX,
.max_rate = INT32_MIN,
.min_ns = INT64_MAX,
.max_ns = INT64_MIN);
*info = SPA_LATENCY_INFO_UNSET(direction);
}
SPA_API_LATENCY_UTILS void
spa_latency_info_combine_finish(struct spa_latency_info *info)
{
if (info->min_quantum == FLT_MAX)
struct spa_latency_info unset = SPA_LATENCY_INFO_UNSET(info->direction);
if (info->min_quantum == unset.min_quantum)
info->min_quantum = 0;
if (info->max_quantum == FLT_MIN)
if (info->max_quantum == unset.max_quantum)
info->max_quantum = 0;
if (info->min_rate == INT32_MAX)
if (info->min_rate == unset.min_rate)
info->min_rate = 0;
if (info->max_rate == INT32_MIN)
if (info->max_rate == unset.max_rate)
info->max_rate = 0;
if (info->min_ns == INT64_MAX)
if (info->min_ns == unset.min_ns)
info->min_ns = 0;
if (info->max_ns == INT64_MIN)
if (info->max_ns == unset.max_ns)
info->max_ns = 0;
}

View file

@ -57,6 +57,10 @@ struct spa_latency_info {
};
#define SPA_LATENCY_INFO(dir,...) ((struct spa_latency_info) { .direction = (dir), ## __VA_ARGS__ })
#define SPA_LATENCY_INFO_UNSET(dir) SPA_LATENCY_INFO(dir, \
.min_quantum = FLT_MAX, .max_quantum = FLT_MIN, \
.min_rate = INT32_MAX, .max_rate = INT32_MIN, \
.min_ns = INT64_MAX, .max_ns = INT64_MIN)
/**
* Properties for SPA_TYPE_OBJECT_ParamProcessLatency