mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
jack: Use latency of sink as buffer size
This commit is contained in:
parent
ce6b75cf63
commit
630dbd2c90
2 changed files with 27 additions and 4 deletions
|
|
@ -70,6 +70,8 @@ struct socket {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
|
uint32_t prop_min_latency;
|
||||||
|
|
||||||
struct pw_core *core;
|
struct pw_core *core;
|
||||||
struct pw_type *t;
|
struct pw_type *t;
|
||||||
struct pw_module *module;
|
struct pw_module *module;
|
||||||
|
|
@ -1284,6 +1286,7 @@ static bool on_global(void *data, struct pw_global *global)
|
||||||
const char *str;
|
const char *str;
|
||||||
char *error;
|
char *error;
|
||||||
struct pw_port *in_port, *out_port;
|
struct pw_port *in_port, *out_port;
|
||||||
|
struct spa_props *props;
|
||||||
|
|
||||||
if (pw_global_get_type(global) != impl->t->node)
|
if (pw_global_get_type(global) != impl->t->node)
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1314,6 +1317,19 @@ static bool on_global(void *data, struct pw_global *global)
|
||||||
free(error);
|
free(error);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spa_node_get_props(node->node, &props) == SPA_RESULT_OK) {
|
||||||
|
int min_latency = -1;
|
||||||
|
|
||||||
|
spa_props_parse(props,
|
||||||
|
":", impl->prop_min_latency, "?i", &min_latency, NULL);
|
||||||
|
|
||||||
|
if (min_latency != -1)
|
||||||
|
jack_engine_control_set_buffer_size(impl->server.engine_control, min_latency);
|
||||||
|
}
|
||||||
|
pw_log_debug("module-jack %p: using buffer_size %d", impl,
|
||||||
|
impl->server.engine_control->buffer_size);
|
||||||
|
|
||||||
pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module));
|
pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1487,6 +1503,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
||||||
impl->t = pw_core_get_type(core);
|
impl->t = pw_core_get_type(core);
|
||||||
impl->module = module;
|
impl->module = module;
|
||||||
impl->properties = properties;
|
impl->properties = properties;
|
||||||
|
impl->prop_min_latency = spa_type_map_get_id(impl->t->map, SPA_TYPE_PROPS__minLatency);
|
||||||
|
|
||||||
spa_list_init(&impl->socket_list);
|
spa_list_init(&impl->socket_list);
|
||||||
spa_list_init(&impl->client_list);
|
spa_list_init(&impl->client_list);
|
||||||
|
|
|
||||||
|
|
@ -1010,6 +1010,15 @@ static inline uint64_t calc_computation(jack_nframes_t buffer_size)
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
jack_engine_control_set_buffer_size(struct jack_engine_control *ctrl, jack_nframes_t buffer_size)
|
||||||
|
{
|
||||||
|
ctrl->buffer_size = buffer_size;
|
||||||
|
ctrl->period_usecs = 1000000.f / ctrl->sample_rate * ctrl->buffer_size;
|
||||||
|
ctrl->period = ctrl->constraint = ctrl->period_usecs * 1000;
|
||||||
|
ctrl->computation = calc_computation(ctrl->buffer_size) * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct jack_engine_control *
|
static inline struct jack_engine_control *
|
||||||
jack_engine_control_alloc(const char* name)
|
jack_engine_control_alloc(const char* name)
|
||||||
{
|
{
|
||||||
|
|
@ -1024,11 +1033,9 @@ jack_engine_control_alloc(const char* name)
|
||||||
ctrl = (struct jack_engine_control *)jack_shm_addr(&info);
|
ctrl = (struct jack_engine_control *)jack_shm_addr(&info);
|
||||||
ctrl->info = info;
|
ctrl->info = info;
|
||||||
|
|
||||||
ctrl->buffer_size = 128;
|
|
||||||
ctrl->sample_rate = 48000;
|
ctrl->sample_rate = 48000;
|
||||||
ctrl->sync_mode = false;
|
ctrl->sync_mode = false;
|
||||||
ctrl->temporary = false;
|
ctrl->temporary = false;
|
||||||
ctrl->period_usecs = 1000000.f / ctrl->sample_rate * ctrl->buffer_size;
|
|
||||||
ctrl->timeout_usecs = 0;
|
ctrl->timeout_usecs = 0;
|
||||||
ctrl->max_delayed_usecs = 0.f;
|
ctrl->max_delayed_usecs = 0.f;
|
||||||
ctrl->xrun_delayed_usecs = 0.f;
|
ctrl->xrun_delayed_usecs = 0.f;
|
||||||
|
|
@ -1050,8 +1057,7 @@ jack_engine_control_alloc(const char* name)
|
||||||
jack_engine_control_reset_rolling_usecs(ctrl);
|
jack_engine_control_reset_rolling_usecs(ctrl);
|
||||||
ctrl->CPU_load = 0.f;
|
ctrl->CPU_load = 0.f;
|
||||||
|
|
||||||
ctrl->period = ctrl->constraint = ctrl->period_usecs * 1000;
|
jack_engine_control_set_buffer_size(ctrl, 128);
|
||||||
ctrl->computation = calc_computation(ctrl->buffer_size) * 1000;
|
|
||||||
|
|
||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue