From 857b2a0cfbae080ec23ad78c61188f0e266244f0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 28 May 2019 13:59:48 +0200 Subject: [PATCH] spa: add result type We need this to know the type of result, especially when serializing. --- spa/include/spa/monitor/device.h | 3 ++- spa/include/spa/monitor/utils.h | 4 ++-- spa/include/spa/node/node.h | 10 +++++++--- spa/include/spa/node/utils.h | 4 ++-- spa/plugins/alsa/alsa-device.c | 3 ++- spa/plugins/alsa/alsa-sink.c | 4 ++-- spa/plugins/alsa/alsa-source.c | 4 ++-- spa/plugins/alsa/alsa-utils.c | 2 +- spa/plugins/audioconvert/audioconvert.c | 8 ++++---- spa/plugins/audioconvert/channelmix.c | 4 ++-- spa/plugins/audioconvert/fmtconvert.c | 2 +- spa/plugins/audioconvert/merger.c | 4 ++-- spa/plugins/audioconvert/resample.c | 2 +- spa/plugins/audioconvert/splitter.c | 4 ++-- spa/plugins/bluez5/a2dp-sink.c | 4 ++-- spa/plugins/bluez5/a2dp-source.c | 4 ++-- spa/plugins/v4l2/v4l2-source.c | 4 ++-- spa/plugins/v4l2/v4l2-utils.c | 4 ++-- spa/tools/spa-inspect.c | 20 +++++++++++++------ src/examples/export-sink.c | 2 +- src/examples/export-source.c | 2 +- src/examples/local-v4l2.c | 2 +- src/modules/module-audio-dsp/floatmix.c | 2 +- src/modules/module-client-node/client-node.c | 8 ++++---- .../module-client-node/client-stream.c | 10 +++++----- src/modules/spa/spa-node.c | 2 +- src/pipewire/device.c | 15 ++++++++++---- src/pipewire/link.c | 4 ++-- src/pipewire/node.c | 20 +++++++++++++------ src/pipewire/node.h | 2 +- src/pipewire/port.c | 16 +++++++++++---- src/pipewire/private.h | 2 +- src/pipewire/stream.c | 2 +- 33 files changed, 110 insertions(+), 73 deletions(-) diff --git a/spa/include/spa/monitor/device.h b/spa/include/spa/monitor/device.h index 1022e8745..b360e82f0 100644 --- a/spa/include/spa/monitor/device.h +++ b/spa/include/spa/monitor/device.h @@ -76,6 +76,7 @@ struct spa_device_object_info { #define SPA_DEVICE_OBJECT_INFO_INIT() (struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, } /** the result of spa_device_enum_params() */ +#define SPA_RESULT_TYPE_DEVICE_PARAMS 1 struct spa_result_device_params { uint32_t id; uint32_t index; @@ -103,7 +104,7 @@ struct spa_device_events { void (*info) (void *data, const struct spa_device_info *info); /** notify a result */ - void (*result) (void *data, int seq, int res, const void *result); + void (*result) (void *data, int seq, int res, uint32_t type, const void *result); /** a device event */ void (*event) (void *data, const struct spa_event *event); diff --git a/spa/include/spa/monitor/utils.h b/spa/include/spa/monitor/utils.h index f964bde32..b7bb2bcdd 100644 --- a/spa/include/spa/monitor/utils.h +++ b/spa/include/spa/monitor/utils.h @@ -37,7 +37,7 @@ struct spa_result_device_params_data { }; static inline void spa_result_func_device_params(void *data, int seq, int res, - const void *result) + uint32_t type, const void *result) { struct spa_result_device_params_data *d = (struct spa_result_device_params_data *)data; @@ -94,7 +94,7 @@ static inline int spa_device_enum_params_sync(struct spa_device *device, method, version, ##__VA_ARGS__) #define spa_device_emit_info(hooks,i) spa_device_emit(hooks,info, 0, i) -#define spa_device_emit_result(hooks,s,r,res) spa_device_emit(hooks,result, 0, s, r, res) +#define spa_device_emit_result(hooks,s,r,t,res) spa_device_emit(hooks,result, 0, s, r, t, res) #define spa_device_emit_event(hooks,e) spa_device_emit(hooks,event, 0, e) #define spa_device_emit_object_info(hooks,id,i) spa_device_emit(hooks,object_info, 0, id, i) diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h index 01b2bd546..1d0c97342 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -112,6 +112,9 @@ struct spa_port_info { #define SPA_PORT_INFO_INIT() (struct spa_port_info) { 0, } +#define SPA_RESULT_TYPE_NODE_ERROR 1 +#define SPA_RESULT_TYPE_NODE_PARAMS 2 + /** an error result */ struct spa_result_node_error { const char *message; @@ -152,8 +155,8 @@ struct spa_node_events { /** notify a result. * * Some methods will trigger a result event with an optional - * result. Look at the documentation of the method to know - * when to expect a result event. + * result of the given type. Look at the documentation of the + * method to know when to expect a result event. * * The result event can be called synchronously, as an event * called from inside the method itself, in which case the seq @@ -165,7 +168,8 @@ struct spa_node_events { * the method call. Users should match the seq number from * request to the reply. */ - void (*result) (void *data, int seq, int res, const void *result); + void (*result) (void *data, int seq, int res, + uint32_t type, const void *result); /** * \param node a spa_node diff --git a/spa/include/spa/node/utils.h b/spa/include/spa/node/utils.h index ece8f9f28..e4e851f6d 100644 --- a/spa/include/spa/node/utils.h +++ b/spa/include/spa/node/utils.h @@ -37,7 +37,7 @@ struct spa_result_node_params_data { }; static inline void spa_result_func_node_params(void *data, - int seq, int res, const void *result) + int seq, int res, uint32_t type, const void *result) { struct spa_result_node_params_data *d = (struct spa_result_node_params_data *) data; @@ -119,7 +119,7 @@ static inline int spa_node_port_enum_params_sync(struct spa_node *node, #define spa_node_emit_info(hooks,i) spa_node_emit(hooks,info, 0, i) #define spa_node_emit_port_info(hooks,d,p,i) spa_node_emit(hooks,port_info, 0, d, p, i) -#define spa_node_emit_result(hooks,s,r,res) spa_node_emit(hooks,result, 0, s, r, res) +#define spa_node_emit_result(hooks,s,r,t,res) spa_node_emit(hooks,result, 0, s, r, t, res) #define spa_node_emit_event(hooks,e) spa_node_emit(hooks,event, 0, e) diff --git a/spa/plugins/alsa/alsa-device.c b/spa/plugins/alsa/alsa-device.c index 981f02fbb..39777fe66 100644 --- a/spa/plugins/alsa/alsa-device.c +++ b/spa/plugins/alsa/alsa-device.c @@ -340,7 +340,8 @@ static int impl_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_device_emit_result(&this->hooks, seq, 0, &result); + spa_device_emit_result(&this->hooks, seq, 0, + SPA_RESULT_TYPE_DEVICE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index af5e2bf39..b69d7a4df 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -142,7 +142,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -400,7 +400,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index faf199197..e3f8bbc3c 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -139,7 +139,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -404,7 +404,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 87582c1ca..766afb265 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -359,7 +359,7 @@ spa_alsa_enum_format(struct state *state, int seq, uint32_t start, uint32_t num, if ((res = spa_pod_filter(&b, &result.param, fmt, filter)) < 0) goto next; - spa_node_emit_result(&state->hooks, seq, 0, &result); + spa_node_emit_result(&state->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 0a6365fe3..49437aae8 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -445,7 +445,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -563,11 +563,11 @@ static int impl_node_send_command(void *object, const struct spa_command *comman return 0; } -static void on_node_result(void *data, int seq, int res, const void *result) +static void on_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *this = data; spa_log_debug(this->log, "%p: result %d %d", this, seq, res); - spa_node_emit_result(&this->hooks, seq, res, result); + spa_node_emit_result(&this->hooks, seq, res, type, result); } static void fmt_input_port_info(void *data, @@ -742,7 +742,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index de8e47a48..5103ade7b 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -294,7 +294,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -588,7 +588,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index a19840073..5ef4cd85e 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -510,7 +510,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index af3b4064a..258b54419 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -224,7 +224,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -513,7 +513,7 @@ impl_node_port_enum_params(void *object, int seq, goto next; } - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 87215f7a5..720f92c2a 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -466,7 +466,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 5b2da589a..c82351424 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -218,7 +218,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -501,7 +501,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index d02303499..548cfb26d 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -225,7 +225,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -1096,7 +1096,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index 04f26bccd..cadb12233 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -201,7 +201,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -751,7 +751,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, NULL) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 79e347491..23329f2d8 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -226,7 +226,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -542,7 +542,7 @@ static int impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 2cbdb7535..c2c9ba1f6 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -815,7 +815,7 @@ spa_v4l2_enum_format(struct impl *this, int seq, spa_pod_builder_pop(&b, &f[1]); result.param = spa_pod_builder_pop(&b, &f[0]); - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -1144,7 +1144,7 @@ spa_v4l2_enum_controls(struct impl *this, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index c2eeee50d..41c8f9ca8 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -52,14 +52,22 @@ struct data { struct spa_hook listener; }; -static void print_param(void *data, int seq, int res, const void *result) +static void print_param(void *data, int seq, int res, uint32_t type, const void *result) { - const struct spa_result_node_params *r = result; + switch (type) { + case SPA_RESULT_TYPE_NODE_PARAMS: + { + const struct spa_result_node_params *r = result; - if (spa_pod_is_object_type(r->param, SPA_TYPE_OBJECT_Format)) - spa_debug_format(16, NULL, r->param); - else - spa_debug_pod(16, NULL, r->param); + if (spa_pod_is_object_type(r->param, SPA_TYPE_OBJECT_Format)) + spa_debug_format(16, NULL, r->param); + else + spa_debug_pod(16, NULL, r->param); + break; + } + default: + break; + } } static void diff --git a/src/examples/export-sink.c b/src/examples/export-sink.c index ab7505f73..bda83d0b3 100644 --- a/src/examples/export-sink.c +++ b/src/examples/export-sink.c @@ -280,7 +280,7 @@ static int impl_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&d->hooks, seq, 0, &result); + spa_node_emit_result(&d->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/src/examples/export-source.c b/src/examples/export-source.c index edbf52025..eae25bee9 100644 --- a/src/examples/export-source.c +++ b/src/examples/export-source.c @@ -252,7 +252,7 @@ static int impl_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&d->hooks, seq, 0, &result); + spa_node_emit_result(&d->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index f20b2b70b..5dc3a59c7 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -192,7 +192,7 @@ static int impl_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&d->hooks, seq, 0, &result); + spa_node_emit_result(&d->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/src/modules/module-audio-dsp/floatmix.c b/src/modules/module-audio-dsp/floatmix.c index 1e1fa9e13..3840fdd86 100644 --- a/src/modules/module-audio-dsp/floatmix.c +++ b/src/modules/module-audio-dsp/floatmix.c @@ -416,7 +416,7 @@ impl_node_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index bc2f59a03..6e9ac3e9a 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -416,7 +416,7 @@ static int impl_node_enum_params(void *object, int seq, continue; pw_log_debug("client-node %p: %d param %u", this, seq, result.index); - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count == num) break; @@ -706,7 +706,7 @@ impl_node_port_enum_params(void *object, int seq, continue; pw_log_debug("client-node %p: %d param %u", this, seq, result.index); - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count == num) break; @@ -1245,7 +1245,7 @@ static void client_node_resource_error(void *data, int seq, int res, const char pw_log_error("client-node %p: error seq:%d %d (%s)", this, seq, res, message); result.message = message; - spa_node_emit_result(&this->hooks, seq, res, &result); + spa_node_emit_result(&this->hooks, seq, res, SPA_RESULT_TYPE_NODE_ERROR, &result); } static void client_node_resource_pong(void *data, int seq) @@ -1254,7 +1254,7 @@ static void client_node_resource_pong(void *data, int seq) struct node *this = &impl->node; pw_log_debug("client-node %p: got pong, emit result %d", this, seq); - spa_node_emit_result(&this->hooks, seq, 0, NULL); + spa_node_emit_result(&this->hooks, seq, 0, 0, NULL); } void pw_client_node_registered(struct pw_client_node *this, struct pw_global *global) diff --git a/src/modules/module-client-node/client-stream.c b/src/modules/module-client-node/client-stream.c index 21d281b72..7ffad147f 100644 --- a/src/modules/module-client-node/client-stream.c +++ b/src/modules/module-client-node/client-stream.c @@ -167,7 +167,7 @@ static int impl_node_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - spa_node_emit_result(&this->hooks, seq, 0, &result); + spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count != num) goto next; @@ -325,12 +325,12 @@ static void adapter_port_info(void *data, } } -static void adapter_result(void *data, int seq, int res, const void *result) +static void adapter_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; struct node *this = &impl->node; pw_log_debug("%p: result %d %d", this, seq, res); - spa_node_emit_result(&this->hooks, seq, res, result); + spa_node_emit_result(&this->hooks, seq, res, type, result); } static const struct spa_node_events adapter_node_events = { @@ -1144,12 +1144,12 @@ static void client_node_free(void *data) cleanup(impl); } -static void client_node_result(void *data, int seq, int res, const void *result) +static void client_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; struct node *node = &impl->node; pw_log_debug("client-stream %p: result %d %d", &impl->this, seq, res); - spa_node_emit_result(&node->hooks, seq, res, result); + spa_node_emit_result(&node->hooks, seq, res, type, result); } static void client_node_active_changed(void *data, bool active) diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index c5e40a8e8..427ba8b38 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -97,7 +97,7 @@ static void complete_init(struct impl *impl) pw_node_initialized(this); } -static void spa_node_result(void *data, int seq, int res, const void *result) +static void spa_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; struct pw_node *node = impl->this; diff --git a/src/pipewire/device.c b/src/pipewire/device.c index 6c9960c98..3a2cff2ec 100644 --- a/src/pipewire/device.c +++ b/src/pipewire/device.c @@ -140,12 +140,19 @@ struct result_device_params_data { struct spa_pod *param); }; -static void result_device_params(void *data, int seq, int res, const void *result) +static void result_device_params(void *data, int seq, int res, uint32_t type, const void *result) { struct result_device_params_data *d = data; - const struct spa_result_device_params *r = - (const struct spa_result_device_params *)result; - d->callback(d->data, seq, r->id, r->index, r->next, r->param); + switch (type) { + case SPA_RESULT_TYPE_DEVICE_PARAMS: + { + const struct spa_result_device_params *r = result; + d->callback(d->data, seq, r->id, r->index, r->next, r->param); + break; + } + default: + break; + } } SPA_EXPORT diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 928c6edf3..9a9326457 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1081,7 +1081,7 @@ static const struct pw_port_events output_port_events = { .destroy = output_port_destroy, }; -static void input_node_result(void *data, int seq, int res, const void *result) +static void input_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; struct pw_node *node = impl->this.input->node; @@ -1091,7 +1091,7 @@ static void input_node_result(void *data, int seq, int res, const void *result) } } -static void output_node_result(void *data, int seq, int res, const void *result) +static void output_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; struct pw_node *node = impl->this.output->node; diff --git a/src/pipewire/node.c b/src/pipewire/node.c index a7b25f1e6..7c31182c8 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -983,7 +983,7 @@ static void node_port_info(void *data, enum spa_direction direction, uint32_t po } } -static void node_result(void *data, int seq, int res, const void *result) +static void node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct pw_node *node = data; struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this); @@ -994,7 +994,7 @@ static void node_result(void *data, int seq, int res, const void *result) if (SPA_RESULT_IS_ASYNC(seq)) pw_work_queue_complete(impl->work, &impl->this, SPA_RESULT_ASYNC_SEQ(seq), res); - pw_node_emit_result(node, seq, res, result); + pw_node_emit_result(node, seq, res, type, result); } static void node_event(void *data, const struct spa_event *event) @@ -1222,12 +1222,20 @@ struct result_node_params_data { int seq; }; -static void result_node_params(void *data, int seq, int res, const void *result) +static void result_node_params(void *data, int seq, int res, uint32_t type, const void *result) { struct result_node_params_data *d = data; - const struct spa_result_node_params *r = result; - if (d->seq == seq) - d->callback(d->data, seq, r->id, r->index, r->next, r->param); + switch (type) { + case SPA_RESULT_TYPE_NODE_PARAMS: + { + const struct spa_result_node_params *r = result; + if (d->seq == seq) + d->callback(d->data, seq, r->id, r->index, r->next, r->param); + break; + } + default: + break; + } } SPA_EXPORT diff --git a/src/pipewire/node.h b/src/pipewire/node.h index 03561438a..0f1a4c0b6 100644 --- a/src/pipewire/node.h +++ b/src/pipewire/node.h @@ -85,7 +85,7 @@ struct pw_node_events { enum pw_node_state state, const char *error); /** a result was received */ - void (*result) (void *data, int seq, int res, const void *result); + void (*result) (void *data, int seq, int res, uint32_t type, const void *result); /** an event is emited */ void (*event) (void *data, const struct spa_event *event); diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 2ea4ab184..80107a9c3 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -836,12 +836,20 @@ struct result_port_params_data { int seq; }; -static void result_port_params(void *data, int seq, int res, const void *result) +static void result_port_params(void *data, int seq, int res, uint32_t type, const void *result) { struct result_port_params_data *d = data; - const struct spa_result_node_params *r = result; - if (d->seq == seq) - d->callback(d->data, seq, r->id, r->index, r->next, r->param); + switch (type) { + case SPA_RESULT_TYPE_NODE_PARAMS: + { + const struct spa_result_node_params *r = result; + if (d->seq == seq) + d->callback(d->data, seq, r->id, r->index, r->next, r->param); + break; + } + default: + break; + } } int pw_port_for_each_param(struct pw_port *port, diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 9f2857f2f..e341e57ea 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -385,7 +385,7 @@ struct pw_node_activation { #define pw_node_emit_state_request(n,s) pw_node_emit(n, state_request, 0, s) #define pw_node_emit_state_changed(n,o,s,e) pw_node_emit(n, state_changed, 0, o, s, e) #define pw_node_emit_async_complete(n,s,r) pw_node_emit(n, async_complete, 0, s, r) -#define pw_node_emit_result(n,s,r,result) pw_node_emit(n, result, 0, s, r, result) +#define pw_node_emit_result(n,s,r,t,result) pw_node_emit(n, result, 0, s, r, t, result) #define pw_node_emit_event(n,e) pw_node_emit(n, event, 0, e) #define pw_node_emit_driver_changed(n,o,d) pw_node_emit(n, driver_changed, 0, o, d) #define pw_node_emit_peer_added(n,p) pw_node_emit(n, peer_added, 0, p) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index ff6ab839e..235e1c5ce 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -466,7 +466,7 @@ static int impl_port_enum_params(void *object, int seq, if (spa_pod_filter(&b, &result.param, param, filter) != 0) continue; - spa_node_emit_result(&d->hooks, seq, 0, &result); + spa_node_emit_result(&d->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); if (++count == num) break;