From ea7e0e9152cf76c53a066905b031d75f1bdc6456 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 20 Jun 2024 10:22:45 +0200 Subject: [PATCH] spa: revert peer_enum_params node event again It's not used anymore because it does work so well. The problem is that while it transparently proxies param enums on ports to peers, it fails to emit events when those peer params change in a way that would make the enum result change as well. This makes it quite hard to use this correctly. --- spa/include/spa/node/node.h | 22 +++------------ spa/include/spa/node/utils.h | 1 - spa/plugins/audiomixer/audiomixer.c | 17 ------------ spa/plugins/audiomixer/mixer-dsp.c | 17 ------------ spa/plugins/control/mixer.c | 17 ------------ src/pipewire/impl-port.c | 42 ----------------------------- test/test-spa-node.c | 9 +------ 7 files changed, 4 insertions(+), 121 deletions(-) diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h index 629b249c9..44e45da83 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -30,7 +30,7 @@ extern "C" { #define SPA_TYPE_INTERFACE_Node SPA_TYPE_INFO_INTERFACE_BASE "Node" -#define SPA_VERSION_NODE 1 +#define SPA_VERSION_NODE 0 struct spa_node { struct spa_interface iface; }; /** @@ -126,8 +126,7 @@ struct spa_result_node_params { #define SPA_NODE_EVENT_PORT_INFO 1 #define SPA_NODE_EVENT_RESULT 2 #define SPA_NODE_EVENT_EVENT 3 -#define SPA_NODE_EVENT_PEER_ENUM_PARAM 4 -#define SPA_NODE_EVENT_NUM 5 +#define SPA_NODE_EVENT_NUM 4 /** events from the spa_node. * @@ -136,7 +135,7 @@ struct spa_result_node_params { * spa_node_add_listener(). */ struct spa_node_events { -#define SPA_VERSION_NODE_EVENTS 1 +#define SPA_VERSION_NODE_EVENTS 0 uint32_t version; /**< version of this structure */ /** Emitted when info changes */ @@ -174,21 +173,6 @@ struct spa_node_events { * on \a node. */ void (*event) (void *data, const struct spa_event *event); - - /** - * \param data the data when registering the listener - * - * Register the given events and data as a listener to the - * peer of the given port and enumerate the params. - * - * since 1:1 - */ - void (*peer_enum_params) (void *data, int seq, - enum spa_direction direction, uint32_t port_id, - uint32_t id, uint32_t start, uint32_t max, - const struct spa_pod *filter, - const struct spa_node_events *events, void *events_data, - int *res); }; #define SPA_NODE_CALLBACK_READY 0 diff --git a/spa/include/spa/node/utils.h b/spa/include/spa/node/utils.h index e482ca4f6..01d249ab9 100644 --- a/spa/include/spa/node/utils.h +++ b/spa/include/spa/node/utils.h @@ -113,7 +113,6 @@ static inline int spa_node_port_enum_params_sync(struct spa_node *node, #define spa_node_emit_port_info(hooks,...) spa_node_emit(hooks,port_info, 0, __VA_ARGS__) #define spa_node_emit_result(hooks,...) spa_node_emit(hooks,result, 0, __VA_ARGS__) #define spa_node_emit_event(hooks,...) spa_node_emit(hooks,event, 0, __VA_ARGS__) -#define spa_node_emit_peer_enum_params(hooks,...) spa_node_emit(hooks,peer_enum_params,1, __VA_ARGS__) #define spa_node_call(callbacks,method,version,...) \ diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 167022fa5..bab300713 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -368,17 +368,6 @@ static int port_enum_formats(void *object, struct port *port, return 1; } -static void peer_result(void *data, int seq, int res, uint32_t type, const void *result) -{ - struct impl *this = data; - spa_node_emit_result(&this->hooks, seq, res, type, result); -} - -static const struct spa_node_events peer_node_events = { - SPA_VERSION_NODE_EVENTS, - .result = peer_result, -}; - static int impl_node_port_enum_params(void *object, int seq, enum spa_direction direction, uint32_t port_id, @@ -468,12 +457,6 @@ impl_node_port_enum_params(void *object, int seq, return 0; } break; - case SPA_PARAM_Latency: - case SPA_PARAM_Tag: - res = -ENOTSUP; - spa_node_emit_peer_enum_params(&this->hooks, seq, direction, port_id, - id, start, num, filter, &peer_node_events, this, &res); - return res; default: return -ENOENT; } diff --git a/spa/plugins/audiomixer/mixer-dsp.c b/spa/plugins/audiomixer/mixer-dsp.c index 4225d00df..fb396c14e 100644 --- a/spa/plugins/audiomixer/mixer-dsp.c +++ b/spa/plugins/audiomixer/mixer-dsp.c @@ -343,17 +343,6 @@ static int port_enum_formats(void *object, struct port *port, return 1; } -static void peer_result(void *data, int seq, int res, uint32_t type, const void *result) -{ - struct impl *this = data; - spa_node_emit_result(&this->hooks, seq, res, type, result); -} - -static const struct spa_node_events peer_node_events = { - SPA_VERSION_NODE_EVENTS, - .result = peer_result, -}; - static int impl_node_port_enum_params(void *object, int seq, enum spa_direction direction, uint32_t port_id, @@ -445,12 +434,6 @@ next: return 0; } break; - case SPA_PARAM_Latency: - case SPA_PARAM_Tag: - res = -ENOTSUP; - spa_node_emit_peer_enum_params(&this->hooks, seq, direction, port_id, - id, start, num, filter, &peer_node_events, this, &res); - return res; default: return -ENOENT; } diff --git a/spa/plugins/control/mixer.c b/spa/plugins/control/mixer.c index a74f2f697..390a4dab3 100644 --- a/spa/plugins/control/mixer.c +++ b/spa/plugins/control/mixer.c @@ -303,17 +303,6 @@ static int port_enum_formats(void *object, struct port *port, return 1; } -static void peer_result(void *data, int seq, int res, uint32_t type, const void *result) -{ - struct impl *this = data; - spa_node_emit_result(&this->hooks, seq, res, type, result); -} - -static const struct spa_node_events peer_node_events = { - SPA_VERSION_NODE_EVENTS, - .result = peer_result, -}; - static int impl_node_port_enum_params(void *object, int seq, enum spa_direction direction, uint32_t port_id, @@ -388,12 +377,6 @@ next: return 0; } break; - case SPA_PARAM_Latency: - case SPA_PARAM_Tag: - res = -ENOTSUP; - spa_node_emit_peer_enum_params(&this->hooks, seq, direction, port_id, - id, start, num, filter, &peer_node_events, this, &res); - return res; default: return -ENOENT; } diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index 5a784dfff..938fa600f 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -30,7 +30,6 @@ struct impl { struct pw_impl_port this; struct spa_node mix_node; /**< mix node implementation */ struct spa_hook_list mix_hooks; - struct spa_hook mix_listener; struct { struct spa_list mix_list; @@ -128,17 +127,6 @@ static int mix_add_listener(void *object, struct spa_hook *listener, return 0; } -static void mix_result(void *data, int seq, int res, uint32_t type, const void *result) -{ - struct impl *impl = data; - spa_node_emit_result(&impl->mix_hooks, seq, res, type, result); -} - -static const struct spa_node_events mix_node_events = { - SPA_VERSION_NODE_EVENTS, - .result = mix_result, -}; - static int mix_port_enum_params(void *object, int seq, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t start, uint32_t max, @@ -182,8 +170,6 @@ next: break; default: res = -ENOTSUP; - spa_node_emit_peer_enum_params(&impl->mix_hooks, seq, direction, port_id, - id, start, max, filter, &mix_node_events, impl, &res); return res; } @@ -810,30 +796,6 @@ error_no_mem: return NULL; } -static void mix_peer_enum_params(void *data, int seq, - enum spa_direction direction, uint32_t port_id, - uint32_t id, uint32_t start, uint32_t max, - const struct spa_pod *filter, - const struct spa_node_events *events, void *events_data, - int *res) -{ - struct impl *impl = data; - struct pw_impl_port *port = &impl->this; - struct spa_hook listener; - - spa_zero(listener); - spa_node_add_listener(port->node->node, &listener, events, events_data); - *res = spa_node_port_enum_params(port->node->node, seq, - port->direction, port->port_id, - id, start, max, filter); - spa_hook_remove(&listener); -} - -static const struct spa_node_events mix_peer_node_events = { - SPA_VERSION_NODE_EVENTS, - .peer_enum_params = mix_peer_enum_params, -}; - SPA_EXPORT int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint32_t flags) { @@ -855,8 +817,6 @@ int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint3 pw_direction_reverse(port->direction), 0, SPA_IO_Buffers, NULL, 0); } - if (port->mix) - spa_hook_remove(&impl->mix_listener); if (port->mix_handle != NULL) { pw_unload_spa_handle(port->mix_handle); @@ -865,8 +825,6 @@ int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint3 port->mix_flags = flags; port->mix = node; - if (port->mix) - spa_node_add_listener(port->mix, &impl->mix_listener, &mix_peer_node_events, impl); if (port->mix && !port->destroying) { spa_list_for_each(mix, &port->mix_list, link) diff --git a/test/test-spa-node.c b/test/test-spa-node.c index 4b91d3c76..09f783eef 100644 --- a/test/test-spa-node.c +++ b/test/test-spa-node.c @@ -126,12 +126,6 @@ PWTEST(node_node_abi) void (*result) (void *data, int seq, int res, uint32_t type, const void *result); void (*event) (void *data, const struct spa_event *event); - void (*peer_enum_params) (void *data, int seq, - enum spa_direction direction, uint32_t port_id, - uint32_t id, uint32_t start, uint32_t max, - const struct spa_pod *filter, - const struct spa_node_events *events, void *events_data, - int *res); } events = { SPA_VERSION_NODE_EVENTS, }; struct { uint32_t version; @@ -195,8 +189,7 @@ PWTEST(node_node_abi) TEST_FUNC(e, events, port_info, SPA_NODE_EVENT_PORT_INFO); TEST_FUNC(e, events, result, SPA_NODE_EVENT_RESULT); TEST_FUNC(e, events, event, SPA_NODE_EVENT_EVENT); - TEST_FUNC(e, events, peer_enum_params, SPA_NODE_EVENT_PEER_ENUM_PARAM); - pwtest_int_eq(SPA_NODE_EVENT_NUM, 5); + pwtest_int_eq(SPA_NODE_EVENT_NUM, 4); pwtest_int_eq(sizeof(e), sizeof(events)); TEST_FUNC(c, callbacks, version, 0);