mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Param: add process latency param and info
This commit is contained in:
parent
8c77713a7b
commit
79866a93cd
7 changed files with 97 additions and 4 deletions
|
|
@ -27,6 +27,9 @@
|
|||
#include <math.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <spa/pod/builder.h>
|
||||
#include <spa/param/latency-utils.h>
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <pipewire/filter.h>
|
||||
|
||||
|
|
@ -87,6 +90,9 @@ static void do_quit(void *userdata, int signal_number)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct data data = { 0, };
|
||||
const struct spa_pod *params[1];
|
||||
uint8_t buffer[1024];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||
|
||||
pw_init(&argc, &argv);
|
||||
|
||||
|
|
@ -138,11 +144,18 @@ int main(int argc, char *argv[])
|
|||
NULL),
|
||||
NULL, 0);
|
||||
|
||||
params[0] = spa_process_latency_build(&b,
|
||||
SPA_PARAM_ProcessLatency,
|
||||
&SPA_PROCESS_LATENCY_INFO_INIT(
|
||||
.ns = 10 * SPA_NSEC_PER_MSEC
|
||||
));
|
||||
|
||||
|
||||
/* Now connect this filter. We ask that our process function is
|
||||
* called in a realtime thread. */
|
||||
if (pw_filter_connect(data.filter,
|
||||
PW_FILTER_FLAG_RT_PROCESS,
|
||||
NULL, 0) < 0) {
|
||||
params, 1) < 0) {
|
||||
fprintf(stderr, "can't connect\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,10 +147,13 @@ struct filter {
|
|||
uint32_t change_mask_all;
|
||||
struct spa_node_info info;
|
||||
struct spa_list param_list;
|
||||
#define IDX_Props 0
|
||||
#define N_NODE_PARAMS 1
|
||||
#define IDX_Props 0
|
||||
#define IDX_ProcessLatency 1
|
||||
#define N_NODE_PARAMS 2
|
||||
struct spa_param_info params[N_NODE_PARAMS];
|
||||
|
||||
struct spa_process_latency_info process_latency;
|
||||
|
||||
struct data data;
|
||||
uintptr_t seq;
|
||||
struct pw_time time;
|
||||
|
|
@ -173,6 +176,8 @@ static int get_param_index(uint32_t id)
|
|||
switch (id) {
|
||||
case SPA_PARAM_Props:
|
||||
return IDX_Props;
|
||||
case SPA_PARAM_ProcessLatency:
|
||||
return IDX_ProcessLatency;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -236,6 +241,8 @@ static struct param *add_param(struct filter *impl, struct port *port,
|
|||
}
|
||||
}
|
||||
}
|
||||
if (id == SPA_PARAM_ProcessLatency && port == NULL)
|
||||
spa_process_latency_parse(param, &impl->process_latency);
|
||||
|
||||
p->id = id;
|
||||
p->flags = flags;
|
||||
|
|
@ -732,6 +739,9 @@ static int default_latency(struct filter *impl, struct port *port, enum spa_dire
|
|||
continue;
|
||||
spa_latency_info_combine(&info, &p->latency[direction]);
|
||||
}
|
||||
|
||||
spa_process_latency_info_add(&impl->process_latency, &info);
|
||||
|
||||
spa_list_for_each(p, &impl->port_list, link) {
|
||||
uint8_t buffer[4096];
|
||||
struct spa_pod_builder b;
|
||||
|
|
@ -1431,6 +1441,7 @@ pw_filter_connect(struct pw_filter *filter,
|
|||
impl->info.flags = impl->process_rt ? SPA_NODE_FLAG_RT : 0;
|
||||
impl->info.props = &filter->properties->dict;
|
||||
impl->params[IDX_Props] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_WRITE);
|
||||
impl->params[IDX_ProcessLatency] = SPA_PARAM_INFO(SPA_PARAM_ProcessLatency, SPA_PARAM_INFO_WRITE);
|
||||
impl->info.params = impl->params;
|
||||
impl->info.n_params = N_NODE_PARAMS;
|
||||
impl->info.change_mask = impl->change_mask_all;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue