handle: make method to get size

This commit is contained in:
Wim Taymans 2018-04-09 10:06:17 +02:00
parent 11f42d6262
commit de36330917
37 changed files with 198 additions and 39 deletions

View file

@ -107,9 +107,14 @@ struct spa_handle_factory {
*/
const struct spa_dict *info;
/**
* The size of handles from this factory
* Get the size of handles from this factory.
*
* \param factory a spa_handle_factory
* \param params extra parameters that determine the size of the
* handle.
*/
const size_t size;
size_t (*get_size) (const struct spa_handle_factory *factory,
const struct spa_dict *params);
/**
* Initialize an instance of this factory. The caller should allocate
@ -150,6 +155,7 @@ struct spa_handle_factory {
uint32_t *index);
};
#define spa_handle_factory_get_size(h,...) (h)->get_size((h),__VA_ARGS__)
#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
#define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__)

View file

@ -479,6 +479,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -545,7 +552,7 @@ const struct spa_handle_factory spa_alsa_monitor_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -658,6 +658,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct state);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle, const struct spa_dict *info, const struct spa_support *support, uint32_t n_support)
@ -754,7 +761,7 @@ const struct spa_handle_factory spa_alsa_sink_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
&info,
sizeof(struct state),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -713,6 +713,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct state);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -812,7 +819,7 @@ const struct spa_handle_factory spa_alsa_source_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
&info,
sizeof(struct state),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -898,6 +898,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -974,7 +981,7 @@ const struct spa_handle_factory spa_audioconvert_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -871,6 +871,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -947,7 +954,7 @@ const struct spa_handle_factory spa_channelmix_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -927,6 +927,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1003,7 +1010,7 @@ const struct spa_handle_factory spa_fmtconvert_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -1114,6 +1114,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1187,7 +1194,7 @@ const struct spa_handle_factory spa_audiomixer_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -1146,6 +1146,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1250,7 +1257,7 @@ const struct spa_handle_factory spa_audiotestsrc_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
&info,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -1340,6 +1340,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1439,7 +1446,7 @@ struct spa_handle_factory spa_a2dp_sink_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
&info,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -1180,6 +1180,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct spa_bt_monitor);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1257,7 +1264,7 @@ static const struct spa_handle_factory spa_bluez5_monitor_factory = {
SPA_VERSION_MONITOR,
NAME,
NULL,
sizeof(struct spa_bt_monitor),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -353,6 +353,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -426,7 +433,7 @@ static const struct spa_handle_factory dbus_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -180,6 +180,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -259,7 +266,7 @@ static const struct spa_handle_factory logger_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -690,6 +690,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -766,7 +773,7 @@ static const struct spa_handle_factory loop_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info
};

View file

@ -154,6 +154,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -206,7 +213,7 @@ static const struct spa_handle_factory type_map_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -840,6 +840,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -929,7 +936,7 @@ const struct spa_handle_factory spa_fakesink_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -875,6 +875,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -964,7 +971,7 @@ const struct spa_handle_factory spa_fakesrc_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -337,6 +337,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -403,7 +410,7 @@ const struct spa_handle_factory spa_v4l2_monitor_factory = {
SPA_VERSION_MONITOR,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -975,6 +975,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1065,7 +1072,7 @@ const struct spa_handle_factory spa_v4l2_source_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -986,6 +986,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -1085,7 +1092,7 @@ const struct spa_handle_factory spa_videotestsrc_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
&info,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -899,6 +899,13 @@ static int impl_clear(struct spa_handle *handle)
return 0;
}
static size_t
impl_get_size(const struct spa_handle_factory *factory,
const struct spa_dict *params)
{
return sizeof(struct impl);
}
static int
impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle,
@ -971,7 +978,7 @@ const struct spa_handle_factory spa_volume_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
sizeof(struct impl),
impl_get_size,
impl_init,
impl_enum_interface_info,
};

View file

@ -188,7 +188,7 @@ static int get_handle(struct data *data,
if (strcmp(factory->name, name))
continue;
*handle = calloc(1, factory->size);
*handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = spa_handle_factory_init(factory, *handle, NULL,
data->support,
data->n_support)) < 0) {

View file

@ -216,7 +216,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -183,7 +183,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -144,7 +144,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -213,7 +213,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -233,7 +233,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -209,7 +209,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -187,7 +187,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -155,7 +155,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
if (strcmp(factory->name, name))
continue;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) {

View file

@ -210,7 +210,7 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
printf(" interface: '%s'\n", info->type);
}
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, data->n_support)) < 0) {
printf("can't make factory instance: %d\n", res);

View file

@ -224,7 +224,7 @@ int main(int argc, char *argv[])
struct spa_handle *handle;
void *interface;
handle = calloc(1, factory->size);
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res =
spa_handle_factory_init(factory, handle, NULL, data.support,
data.n_support)) < 0) {