mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
spa: add result type
We need this to know the type of result, especially when serializing.
This commit is contained in:
parent
c767ce62c9
commit
857b2a0cfb
33 changed files with 110 additions and 73 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue