mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
hooks: enforce version on hook emission
Pass the minimum required version to the hook emission and only call events when the handler is recent enough. Add some macros to make event emission easier to read.
This commit is contained in:
parent
a72e3cefd7
commit
a63523650d
27 changed files with 250 additions and 155 deletions
|
|
@ -183,7 +183,7 @@ static int client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
|||
|
||||
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_mem,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_mem, 0,
|
||||
mem_id,
|
||||
type,
|
||||
memfd, flags);
|
||||
|
|
@ -211,7 +211,7 @@ static int client_node_demarshal_transport(void *object, void *data, size_t size
|
|||
if (readfd == -1 || writefd == -1)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, node_id,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, 0, node_id,
|
||||
readfd, writefd);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ static int client_node_demarshal_set_param(void *object, void *data, size_t size
|
|||
"O", ¶m, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, seq, id, flags, param);
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, 0, seq, id, flags, param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ static int client_node_demarshal_event_event(void *object, void *data, size_t si
|
|||
if (spa_pod_parser_get(&prs, "[ O", &event, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, event, event);
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, event, 0, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ static int client_node_demarshal_command(void *object, void *data, size_t size)
|
|||
"O", &command, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, seq, command);
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, 0, seq, command);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ static int client_node_demarshal_add_port(void *object, void *data, size_t size)
|
|||
"i", &port_id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, seq, direction, port_id);
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, 0, seq, direction, port_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ static int client_node_demarshal_remove_port(void *object, void *data, size_t si
|
|||
"i", &port_id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, seq, direction, port_id);
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, 0, seq, direction, port_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ static int client_node_demarshal_port_set_param(void *object, void *data, size_t
|
|||
"O", ¶m, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param, 0,
|
||||
seq, direction, port_id, id, flags, param);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
|
|||
d->data = SPA_UINT32_TO_PTR(data_id);
|
||||
}
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, seq,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, 0, seq,
|
||||
direction,
|
||||
port_id,
|
||||
mix_id,
|
||||
|
|
@ -407,7 +407,7 @@ static int client_node_demarshal_port_command(void *object, void *data, size_t s
|
|||
"O", &command, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_command, direction,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_command, 0, direction,
|
||||
port_id,
|
||||
command);
|
||||
return 0;
|
||||
|
|
@ -432,7 +432,7 @@ static int client_node_demarshal_port_set_io(void *object, void *data, size_t si
|
|||
"i", &sz, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io, 0,
|
||||
seq,
|
||||
direction, port_id, mix_id,
|
||||
id, memid,
|
||||
|
|
@ -455,7 +455,7 @@ static int client_node_demarshal_set_io(void *object, void *data, size_t size)
|
|||
"i", &sz, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_io,
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_io, 0,
|
||||
id, memid, off, sz);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -731,7 +731,7 @@ static int client_node_demarshal_done(void *object, void *data, size_t size)
|
|||
"i", &res, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, done, seq, res);
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, done, 0, seq, res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -771,7 +771,7 @@ static int client_node_demarshal_update(void *object, void *data, size_t size)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, update, change_mask,
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, update, 0, change_mask,
|
||||
max_input_ports,
|
||||
max_output_ports,
|
||||
n_params,
|
||||
|
|
@ -834,7 +834,7 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
|
|||
}
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, direction,
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, 0, direction,
|
||||
port_id,
|
||||
change_mask,
|
||||
n_params,
|
||||
|
|
@ -854,7 +854,7 @@ static int client_node_demarshal_set_active(void *object, void *data, size_t siz
|
|||
"b", &active, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, set_active, active);
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, set_active, 0, active);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -870,7 +870,7 @@ static int client_node_demarshal_event_method(void *object, void *data, size_t s
|
|||
"O", &event, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, event, event);
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, event, 0, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -883,7 +883,7 @@ static int client_node_demarshal_destroy(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[", NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, destroy);
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, destroy, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static void *connection_ensure_size(struct pw_protocol_native_connection *conn,
|
|||
buf->buffer_data = realloc(buf->buffer_data, buf->buffer_maxsize);
|
||||
if (buf->buffer_data == NULL) {
|
||||
buf->buffer_maxsize = 0;
|
||||
spa_hook_list_call(&conn->listener_list, struct pw_protocol_native_connection_events, error, -ENOMEM);
|
||||
spa_hook_list_call(&conn->listener_list, struct pw_protocol_native_connection_events, error, 0, -ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
pw_log_warn("connection %p: resize buffer to %zd %zd %zd",
|
||||
|
|
@ -241,7 +241,7 @@ void pw_protocol_native_connection_destroy(struct pw_protocol_native_connection
|
|||
|
||||
pw_log_debug("connection %p: destroy", conn);
|
||||
|
||||
spa_hook_list_call(&conn->listener_list, struct pw_protocol_native_connection_events, destroy);
|
||||
spa_hook_list_call(&conn->listener_list, struct pw_protocol_native_connection_events, destroy, 0);
|
||||
|
||||
free(impl->out.buffer_data);
|
||||
free(impl->in.buffer_data);
|
||||
|
|
@ -435,7 +435,7 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
|
|||
spa_debug_pod((struct spa_pod *)p, 0);
|
||||
}
|
||||
spa_hook_list_call(&conn->listener_list,
|
||||
struct pw_protocol_native_connection_events, need_flush);
|
||||
struct pw_protocol_native_connection_events, need_flush, 0);
|
||||
}
|
||||
|
||||
/** Flush the connection object
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ extern "C" {
|
|||
|
||||
struct pw_protocol_native_connection_events {
|
||||
#define PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*destroy) (void *data);
|
||||
|
||||
void (*error) (void *data, int error);
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ static int core_demarshal_info(void *object, void *data, size_t size)
|
|||
NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ static int core_demarshal_done(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[ i", &seq, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, done, seq);
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, done, 0, seq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ static int core_demarshal_error(void *object, void *data, size_t size)
|
|||
"s", &error, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, error, id, res, error);
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, error, 0, id, res, error);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ static int core_demarshal_remove_id(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[ i", &id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, remove_id, id);
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, remove_id, 0, id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ static int core_demarshal_update_types_client(void *object, void *data, size_t s
|
|||
if (spa_pod_parser_get(&prs, "s", &types[i], NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, update_types, first_id, types, n_types);
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, update_types, 0, first_id, types, n_types);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ static int core_demarshal_client_update(void *object, void *data, size_t size)
|
|||
NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, client_update, &props);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, client_update, 0, &props);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -424,7 +424,7 @@ static int core_demarshal_permissions(void *object, void *data, size_t size)
|
|||
NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, permissions, &props);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, permissions, 0, &props);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -438,7 +438,7 @@ static int core_demarshal_hello(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[P]", &ptr, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, hello);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, hello, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ static int core_demarshal_sync(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[i]", &seq, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, sync, seq);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, sync, 0, seq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ static int core_demarshal_get_registry(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[ii]", &version, &new_id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, get_registry, version, new_id);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, get_registry, 0, version, new_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -496,7 +496,7 @@ static int core_demarshal_create_object(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "i", &new_id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, create_object, factory_name,
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, create_object, 0, factory_name,
|
||||
type, version,
|
||||
&props, new_id);
|
||||
return 0;
|
||||
|
|
@ -512,7 +512,7 @@ static int core_demarshal_destroy(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs, "[i]", &id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, destroy, id);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, destroy, 0, id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -536,7 +536,7 @@ static int core_demarshal_update_types_server(void *object, void *data, size_t s
|
|||
if (spa_pod_parser_get(&prs, "s", &types[i], NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, update_types, first_id, types, n_types);
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, update_types, 0, first_id, types, n_types);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -597,7 +597,7 @@ static int registry_demarshal_bind(void *object, void *data, size_t size)
|
|||
"i", &new_id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_registry_proxy_methods, bind, id, type, version, new_id);
|
||||
pw_resource_do(resource, struct pw_registry_proxy_methods, bind, 0, id, type, version, new_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -656,7 +656,7 @@ static int module_demarshal_info(void *object, void *data, size_t size)
|
|||
&props.items[i].key, &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_module_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_module_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -716,7 +716,7 @@ static int factory_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_factory_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_factory_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -784,7 +784,7 @@ static int node_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_node_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_node_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -816,7 +816,7 @@ static int node_demarshal_param(void *object, void *data, size_t size)
|
|||
"P", ¶m, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_node_proxy_events, param, id, index, next, param);
|
||||
pw_proxy_notify(proxy, struct pw_node_proxy_events, param, 0, id, index, next, param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -852,7 +852,7 @@ static int node_demarshal_enum_params(void *object, void *data, size_t size)
|
|||
"P", &filter, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_node_proxy_methods, enum_params, id, index, num, filter);
|
||||
pw_resource_do(resource, struct pw_node_proxy_methods, enum_params, 0, id, index, num, filter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -908,7 +908,7 @@ static int port_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_port_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_port_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -940,7 +940,7 @@ static int port_demarshal_param(void *object, void *data, size_t size)
|
|||
"P", ¶m, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_port_proxy_events, param, id, index, next, param);
|
||||
pw_proxy_notify(proxy, struct pw_port_proxy_events, param, 0, id, index, next, param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -976,7 +976,7 @@ static int port_demarshal_enum_params(void *object, void *data, size_t size)
|
|||
"P", &filter, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_port_proxy_methods, enum_params, id, index, num, filter);
|
||||
pw_resource_do(resource, struct pw_port_proxy_methods, enum_params, 0, id, index, num, filter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1030,7 +1030,7 @@ static int client_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_client_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_client_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1094,7 +1094,7 @@ static int link_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_link_proxy_events, info, &info);
|
||||
pw_proxy_notify(proxy, struct pw_link_proxy_events, info, 0, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1125,7 +1125,7 @@ static int registry_demarshal_global(void *object, void *data, size_t size)
|
|||
}
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events,
|
||||
global, id, parent_id, permissions, type, version,
|
||||
global, 0, id, parent_id, permissions, type, version,
|
||||
props.n_items > 0 ? &props : NULL);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1140,7 +1140,7 @@ static int registry_demarshal_global_remove(void *object, void *data, size_t siz
|
|||
if (spa_pod_parser_get(&prs, "[ i", &id, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events, global_remove, id);
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events, global_remove, 0, id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue