spa: add result type

We need this to know the type of result, especially when serializing.
This commit is contained in:
Wim Taymans 2019-05-28 13:59:48 +02:00
parent c767ce62c9
commit 857b2a0cfb
33 changed files with 110 additions and 73 deletions

View file

@ -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, } #define SPA_DEVICE_OBJECT_INFO_INIT() (struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, }
/** the result of spa_device_enum_params() */ /** the result of spa_device_enum_params() */
#define SPA_RESULT_TYPE_DEVICE_PARAMS 1
struct spa_result_device_params { struct spa_result_device_params {
uint32_t id; uint32_t id;
uint32_t index; uint32_t index;
@ -103,7 +104,7 @@ struct spa_device_events {
void (*info) (void *data, const struct spa_device_info *info); void (*info) (void *data, const struct spa_device_info *info);
/** notify a result */ /** 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 */ /** a device event */
void (*event) (void *data, const struct spa_event *event); void (*event) (void *data, const struct spa_event *event);

View file

@ -37,7 +37,7 @@ struct spa_result_device_params_data {
}; };
static inline void spa_result_func_device_params(void *data, int seq, int res, 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 *d =
(struct spa_result_device_params_data *)data; (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__) method, version, ##__VA_ARGS__)
#define spa_device_emit_info(hooks,i) spa_device_emit(hooks,info, 0, i) #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_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) #define spa_device_emit_object_info(hooks,id,i) spa_device_emit(hooks,object_info, 0, id, i)

View file

@ -112,6 +112,9 @@ struct spa_port_info {
#define SPA_PORT_INFO_INIT() (struct spa_port_info) { 0, } #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 */ /** an error result */
struct spa_result_node_error { struct spa_result_node_error {
const char *message; const char *message;
@ -152,8 +155,8 @@ struct spa_node_events {
/** notify a result. /** notify a result.
* *
* Some methods will trigger a result event with an optional * Some methods will trigger a result event with an optional
* result. Look at the documentation of the method to know * result of the given type. Look at the documentation of the
* when to expect a result event. * method to know when to expect a result event.
* *
* The result event can be called synchronously, as an event * The result event can be called synchronously, as an event
* called from inside the method itself, in which case the seq * 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 * the method call. Users should match the seq number from
* request to the reply. * 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 * \param node a spa_node

View file

@ -37,7 +37,7 @@ struct spa_result_node_params_data {
}; };
static inline void spa_result_func_node_params(void *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 *d =
(struct spa_result_node_params_data *) data; (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_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_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) #define spa_node_emit_event(hooks,e) spa_node_emit(hooks,event, 0, e)

View file

@ -340,7 +340,8 @@ static int impl_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -142,7 +142,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -139,7 +139,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -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) if ((res = spa_pod_filter(&b, &result.param, fmt, filter)) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -445,7 +445,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;
@ -563,11 +563,11 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
return 0; 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; struct impl *this = data;
spa_log_debug(this->log, "%p: result %d %d", this, seq, res); 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, 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -294,7 +294,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -510,7 +510,7 @@ impl_node_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -224,7 +224,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;
@ -513,7 +513,7 @@ impl_node_port_enum_params(void *object, int seq,
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -466,7 +466,7 @@ impl_node_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -218,7 +218,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -225,7 +225,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -201,7 +201,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, NULL) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -226,7 +226,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -815,7 +815,7 @@ spa_v4l2_enum_format(struct impl *this, int seq,
spa_pod_builder_pop(&b, &f[1]); spa_pod_builder_pop(&b, &f[1]);
result.param = spa_pod_builder_pop(&b, &f[0]); 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) if (++count != num)
goto next; 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) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -52,7 +52,10 @@ struct data {
struct spa_hook listener; 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)
{
switch (type) {
case SPA_RESULT_TYPE_NODE_PARAMS:
{ {
const struct spa_result_node_params *r = result; const struct spa_result_node_params *r = result;
@ -60,6 +63,11 @@ static void print_param(void *data, int seq, int res, const void *result)
spa_debug_format(16, NULL, r->param); spa_debug_format(16, NULL, r->param);
else else
spa_debug_pod(16, NULL, r->param); spa_debug_pod(16, NULL, r->param);
break;
}
default:
break;
}
} }
static void static void

View file

@ -280,7 +280,7 @@ static int impl_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -252,7 +252,7 @@ static int impl_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -192,7 +192,7 @@ static int impl_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -416,7 +416,7 @@ impl_node_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; goto next;

View file

@ -416,7 +416,7 @@ static int impl_node_enum_params(void *object, int seq,
continue; continue;
pw_log_debug("client-node %p: %d param %u", this, seq, result.index); 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) if (++count == num)
break; break;
@ -706,7 +706,7 @@ impl_node_port_enum_params(void *object, int seq,
continue; continue;
pw_log_debug("client-node %p: %d param %u", this, seq, result.index); 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) if (++count == num)
break; 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); pw_log_error("client-node %p: error seq:%d %d (%s)", this, seq, res, message);
result.message = 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) 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; struct node *this = &impl->node;
pw_log_debug("client-node %p: got pong, emit result %d", this, seq); 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) void pw_client_node_registered(struct pw_client_node *this, struct pw_global *global)

View file

@ -167,7 +167,7 @@ static int impl_node_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) < 0) if (spa_pod_filter(&b, &result.param, param, filter) < 0)
goto next; 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) if (++count != num)
goto next; 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 impl *impl = data;
struct node *this = &impl->node; struct node *this = &impl->node;
pw_log_debug("%p: result %d %d", this, seq, res); 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 = { static const struct spa_node_events adapter_node_events = {
@ -1144,12 +1144,12 @@ static void client_node_free(void *data)
cleanup(impl); 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 impl *impl = data;
struct node *node = &impl->node; struct node *node = &impl->node;
pw_log_debug("client-stream %p: result %d %d", &impl->this, seq, res); 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) static void client_node_active_changed(void *data, bool active)

View file

@ -97,7 +97,7 @@ static void complete_init(struct impl *impl)
pw_node_initialized(this); 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 impl *impl = data;
struct pw_node *node = impl->this; struct pw_node *node = impl->this;

View file

@ -140,12 +140,19 @@ struct result_device_params_data {
struct spa_pod *param); 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; struct result_device_params_data *d = data;
const struct spa_result_device_params *r = switch (type) {
(const struct spa_result_device_params *)result; 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); d->callback(d->data, seq, r->id, r->index, r->next, r->param);
break;
}
default:
break;
}
} }
SPA_EXPORT SPA_EXPORT

View file

@ -1081,7 +1081,7 @@ static const struct pw_port_events output_port_events = {
.destroy = output_port_destroy, .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 impl *impl = data;
struct pw_node *node = impl->this.input->node; 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 impl *impl = data;
struct pw_node *node = impl->this.output->node; struct pw_node *node = impl->this.output->node;

View file

@ -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 pw_node *node = data;
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this); 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)) if (SPA_RESULT_IS_ASYNC(seq))
pw_work_queue_complete(impl->work, &impl->this, SPA_RESULT_ASYNC_SEQ(seq), res); 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) static void node_event(void *data, const struct spa_event *event)
@ -1222,12 +1222,20 @@ struct result_node_params_data {
int seq; 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; struct result_node_params_data *d = data;
switch (type) {
case SPA_RESULT_TYPE_NODE_PARAMS:
{
const struct spa_result_node_params *r = result; const struct spa_result_node_params *r = result;
if (d->seq == seq) if (d->seq == seq)
d->callback(d->data, seq, r->id, r->index, r->next, r->param); d->callback(d->data, seq, r->id, r->index, r->next, r->param);
break;
}
default:
break;
}
} }
SPA_EXPORT SPA_EXPORT

View file

@ -85,7 +85,7 @@ struct pw_node_events {
enum pw_node_state state, const char *error); enum pw_node_state state, const char *error);
/** a result was received */ /** 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 */ /** an event is emited */
void (*event) (void *data, const struct spa_event *event); void (*event) (void *data, const struct spa_event *event);

View file

@ -836,12 +836,20 @@ struct result_port_params_data {
int seq; 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; struct result_port_params_data *d = data;
switch (type) {
case SPA_RESULT_TYPE_NODE_PARAMS:
{
const struct spa_result_node_params *r = result; const struct spa_result_node_params *r = result;
if (d->seq == seq) if (d->seq == seq)
d->callback(d->data, seq, r->id, r->index, r->next, r->param); 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, int pw_port_for_each_param(struct pw_port *port,

View file

@ -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_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_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_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_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_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) #define pw_node_emit_peer_added(n,p) pw_node_emit(n, peer_added, 0, p)

View file

@ -466,7 +466,7 @@ static int impl_port_enum_params(void *object, int seq,
if (spa_pod_filter(&b, &result.param, param, filter) != 0) if (spa_pod_filter(&b, &result.param, param, filter) != 0)
continue; 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) if (++count == num)
break; break;