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; 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 * Initialize an instance of this factory. The caller should allocate
@ -150,6 +155,7 @@ struct spa_handle_factory {
uint32_t *index); 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_init(h,...) (h)->init((h),__VA_ARGS__)
#define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((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; 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 static int
impl_init(const struct spa_handle_factory *factory, impl_init(const struct spa_handle_factory *factory,
struct spa_handle *handle, struct spa_handle *handle,
@ -545,7 +552,7 @@ const struct spa_handle_factory spa_alsa_monitor_factory = {
SPA_VERSION_HANDLE_FACTORY, SPA_VERSION_HANDLE_FACTORY,
NAME, NAME,
NULL, NULL,
sizeof(struct impl), impl_get_size,
impl_init, impl_init,
impl_enum_interface_info, impl_enum_interface_info,
}; };

View file

@ -658,6 +658,13 @@ static int impl_clear(struct spa_handle *handle)
return 0; 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 static int
impl_init(const struct spa_handle_factory *factory, 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) 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, SPA_VERSION_HANDLE_FACTORY,
NAME, NAME,
&info, &info,
sizeof(struct state), impl_get_size,
impl_init, impl_init,
impl_enum_interface_info, impl_enum_interface_info,
}; };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -188,7 +188,7 @@ static int get_handle(struct data *data,
if (strcmp(factory->name, name)) if (strcmp(factory->name, name))
continue; 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, if ((res = spa_handle_factory_init(factory, *handle, NULL,
data->support, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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)) if (strcmp(factory->name, name))
continue; continue;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, spa_handle_factory_init(factory, handle, NULL, data->support,
data->n_support)) < 0) { 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); printf(" interface: '%s'\n", info->type);
} }
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data->support, data->n_support)) < 0) { spa_handle_factory_init(factory, handle, NULL, data->support, data->n_support)) < 0) {
printf("can't make factory instance: %d\n", res); 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; struct spa_handle *handle;
void *interface; void *interface;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = if ((res =
spa_handle_factory_init(factory, handle, NULL, data.support, spa_handle_factory_init(factory, handle, NULL, data.support,
data.n_support)) < 0) { data.n_support)) < 0) {

View file

@ -109,7 +109,10 @@ static struct pw_node *make_node(struct impl *impl, struct pw_properties *proper
support = pw_core_get_support(impl->core, &n_support); support = pw_core_get_support(impl->core, &n_support);
handle = calloc(1, impl->factory->size); handle = calloc(1, spa_handle_factory_get_size(impl->factory, NULL));
if (handle == NULL)
goto no_mem;
if ((res = spa_handle_factory_init(impl->factory, if ((res = spa_handle_factory_init(impl->factory,
handle, handle,
NULL, support, n_support)) < 0) { NULL, support, n_support)) < 0) {
@ -140,6 +143,7 @@ static struct pw_node *make_node(struct impl *impl, struct pw_properties *proper
spa_handle_clear(handle); spa_handle_clear(handle);
init_failed: init_failed:
free(handle); free(handle);
no_mem:
return NULL; return NULL;
} }

View file

@ -103,7 +103,7 @@ static void add_item(struct pw_spa_monitor *this, struct spa_pod *item)
support = pw_core_get_support(impl->core, &n_support); support = pw_core_get_support(impl->core, &n_support);
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = spa_handle_factory_init(factory, if ((res = spa_handle_factory_init(factory,
handle, handle,
&props->dict, &props->dict,
@ -292,8 +292,12 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
if (strcmp(factory->name, factory_name) == 0) if (strcmp(factory->name, factory_name) == 0)
break; break;
} }
handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if (handle == NULL)
goto no_mem;
support = pw_core_get_support(core, &n_support); support = pw_core_get_support(core, &n_support);
handle = calloc(1, factory->size);
if ((res = spa_handle_factory_init(factory, if ((res = spa_handle_factory_init(factory,
handle, NULL, support, n_support)) < 0) { handle, NULL, support, n_support)) < 0) {
pw_log_error("can't make factory instance: %d", res); pw_log_error("can't make factory instance: %d", res);
@ -345,6 +349,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
spa_handle_clear(handle); spa_handle_clear(handle);
init_failed: init_failed:
free(handle); free(handle);
no_mem:
enum_failed: enum_failed:
no_symbol: no_symbol:
dlclose(hnd); dlclose(hnd);

View file

@ -279,7 +279,10 @@ struct pw_node *pw_spa_node_load(struct pw_core *core,
support = pw_core_get_support(core, &n_support); support = pw_core_get_support(core, &n_support);
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if (handle == NULL)
goto no_mem;
if ((res = spa_handle_factory_init(factory, if ((res = spa_handle_factory_init(factory,
handle, handle,
properties ? &properties->dict : NULL, properties ? &properties->dict : NULL,
@ -319,6 +322,7 @@ struct pw_node *pw_spa_node_load(struct pw_core *core,
init_failed: init_failed:
free(handle); free(handle);
enum_failed: enum_failed:
no_mem:
no_symbol: no_symbol:
dlclose(hnd); dlclose(hnd);
open_failed: open_failed:

View file

@ -64,7 +64,7 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
if (factory == NULL) if (factory == NULL)
return NULL; return NULL;
impl = calloc(1, sizeof(struct impl) + factory->size); impl = calloc(1, sizeof(struct impl) + spa_handle_factory_get_size(factory, NULL));
if (impl == NULL) if (impl == NULL)
return NULL; return NULL;

View file

@ -107,7 +107,7 @@ load_interface(struct support_info *info,
if (factory == NULL) if (factory == NULL)
goto not_found; goto not_found;
handle = calloc(1, factory->size); handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
if ((res = spa_handle_factory_init(factory, if ((res = spa_handle_factory_init(factory,
handle, NULL, info->support, info->n_support)) < 0) { handle, NULL, info->support, info->n_support)) < 0) {
fprintf(stderr, "can't make factory instance: %d\n", res); fprintf(stderr, "can't make factory instance: %d\n", res);