mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
impl-node: Make rounding of quantum configurable
Add new context config clock.power-of-two-quantum to make it possible to not round quantum to closest lower power of two. This makes it possible to match the quantum of a source node with the quantum of a client node.
This commit is contained in:
parent
d143c169cc
commit
44e0251afd
4 changed files with 24 additions and 15 deletions
|
|
@ -9,6 +9,7 @@ context.properties = {
|
|||
#mem.warn-mlock = false
|
||||
#mem.allow-mlock = true
|
||||
#mem.mlock-all = false
|
||||
#clock.power-of-two-quantum = true
|
||||
#log.level = 2
|
||||
|
||||
core.daemon = true # listening for socket connections
|
||||
|
|
|
|||
|
|
@ -46,20 +46,21 @@
|
|||
|
||||
#define NAME "context"
|
||||
|
||||
#define CLOCK_MIN_QUANTUM 4u
|
||||
#define CLOCK_MAX_QUANTUM 8192u
|
||||
#define CLOCK_MIN_QUANTUM 4u
|
||||
#define CLOCK_MAX_QUANTUM 8192u
|
||||
|
||||
#define DEFAULT_CLOCK_RATE 48000u
|
||||
#define DEFAULT_CLOCK_QUANTUM 1024u
|
||||
#define DEFAULT_CLOCK_MIN_QUANTUM 32u
|
||||
#define DEFAULT_CLOCK_MAX_QUANTUM 8192u
|
||||
#define DEFAULT_VIDEO_WIDTH 640
|
||||
#define DEFAULT_VIDEO_HEIGHT 480
|
||||
#define DEFAULT_VIDEO_RATE_NUM 25u
|
||||
#define DEFAULT_VIDEO_RATE_DENOM 1u
|
||||
#define DEFAULT_LINK_MAX_BUFFERS 64u
|
||||
#define DEFAULT_MEM_WARN_MLOCK false
|
||||
#define DEFAULT_MEM_ALLOW_MLOCK true
|
||||
#define DEFAULT_CLOCK_RATE 48000u
|
||||
#define DEFAULT_CLOCK_QUANTUM 1024u
|
||||
#define DEFAULT_CLOCK_MIN_QUANTUM 32u
|
||||
#define DEFAULT_CLOCK_MAX_QUANTUM 8192u
|
||||
#define DEFAULT_CLOCK_POWER_OF_TWO_QUANTUM true
|
||||
#define DEFAULT_VIDEO_WIDTH 640
|
||||
#define DEFAULT_VIDEO_HEIGHT 480
|
||||
#define DEFAULT_VIDEO_RATE_NUM 25u
|
||||
#define DEFAULT_VIDEO_RATE_DENOM 1u
|
||||
#define DEFAULT_LINK_MAX_BUFFERS 64u
|
||||
#define DEFAULT_MEM_WARN_MLOCK false
|
||||
#define DEFAULT_MEM_ALLOW_MLOCK true
|
||||
|
||||
/** \cond */
|
||||
struct impl {
|
||||
|
|
@ -138,6 +139,8 @@ static bool get_default_bool(struct pw_properties *properties, const char *name,
|
|||
static void fill_defaults(struct pw_context *this)
|
||||
{
|
||||
struct pw_properties *p = this->properties;
|
||||
this->defaults.clock_power_of_two_quantum = get_default_bool(p, "clock.power-of-two-quantum",
|
||||
DEFAULT_CLOCK_POWER_OF_TWO_QUANTUM);
|
||||
this->defaults.clock_rate = get_default_int(p, "default.clock.rate", DEFAULT_CLOCK_RATE);
|
||||
this->defaults.clock_quantum = get_default_int(p, "default.clock.quantum", DEFAULT_CLOCK_QUANTUM);
|
||||
this->defaults.clock_min_quantum = get_default_int(p, "default.clock.min-quantum", DEFAULT_CLOCK_MIN_QUANTUM);
|
||||
|
|
|
|||
|
|
@ -876,7 +876,9 @@ static void check_properties(struct pw_impl_node *node)
|
|||
uint32_t quantum_size;
|
||||
|
||||
node->latency = SPA_FRACTION(num, denom);
|
||||
quantum_size = flp2((num * context->defaults.clock_rate / denom));
|
||||
quantum_size = (num * context->defaults.clock_rate / denom);
|
||||
if (context->defaults.clock_power_of_two_quantum)
|
||||
quantum_size = flp2(quantum_size);
|
||||
|
||||
if (quantum_size != node->quantum_size) {
|
||||
pw_log_debug(NAME" %p: latency '%s' quantum %u/%u",
|
||||
|
|
@ -895,7 +897,9 @@ static void check_properties(struct pw_impl_node *node)
|
|||
uint32_t max_quantum_size;
|
||||
|
||||
node->max_latency = SPA_FRACTION(num, denom);
|
||||
max_quantum_size = flp2((num * context->defaults.clock_rate / denom));
|
||||
max_quantum_size = (num * context->defaults.clock_rate / denom);
|
||||
if (context->defaults.clock_power_of_two_quantum)
|
||||
max_quantum_size = flp2(max_quantum_size);
|
||||
|
||||
if (max_quantum_size != node->max_quantum_size) {
|
||||
pw_log_debug(NAME" %p: max latency '%s' quantum %u/%u",
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ struct defaults {
|
|||
uint32_t link_max_buffers;
|
||||
unsigned int mem_warn_mlock:1;
|
||||
unsigned int mem_allow_mlock:1;
|
||||
unsigned int clock_power_of_two_quantum:1;
|
||||
};
|
||||
|
||||
struct ratelimit {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue