mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
module: handle type register errors
Registering an export type can give an error when the type is already registered. Handle those errors and refuse to load the module. See #2281
This commit is contained in:
parent
37fa911a72
commit
b97327e1f6
7 changed files with 50 additions and 13 deletions
|
|
@ -540,6 +540,7 @@ int endpoint_link_factory_init(struct pw_impl_module *module)
|
|||
struct pw_context *context = pw_impl_module_get_context(module);
|
||||
struct pw_impl_factory *factory;
|
||||
struct factory_data *data;
|
||||
int res;
|
||||
|
||||
factory = pw_context_create_factory(context,
|
||||
"endpoint-link",
|
||||
|
|
@ -558,9 +559,13 @@ int endpoint_link_factory_init(struct pw_impl_module *module)
|
|||
|
||||
data->export.type = PW_TYPE_INTERFACE_EndpointLink;
|
||||
data->export.func = pw_core_endpoint_link_export;
|
||||
pw_context_register_export_type(context, &data->export);
|
||||
if ((res = pw_context_register_export_type(context, &data->export)) < 0)
|
||||
goto error;
|
||||
|
||||
pw_impl_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return 0;
|
||||
error:
|
||||
pw_impl_factory_destroy(data->this);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -531,6 +531,7 @@ int endpoint_stream_factory_init(struct pw_impl_module *module)
|
|||
struct pw_context *context = pw_impl_module_get_context(module);
|
||||
struct pw_impl_factory *factory;
|
||||
struct factory_data *data;
|
||||
int res;
|
||||
|
||||
factory = pw_context_create_factory(context,
|
||||
"endpoint-stream",
|
||||
|
|
@ -549,9 +550,13 @@ int endpoint_stream_factory_init(struct pw_impl_module *module)
|
|||
|
||||
data->export.type = PW_TYPE_INTERFACE_EndpointStream;
|
||||
data->export.func = pw_core_endpoint_stream_export;
|
||||
pw_context_register_export_type(context, &data->export);
|
||||
if ((res = pw_context_register_export_type(context, &data->export)) < 0)
|
||||
goto error;
|
||||
|
||||
pw_impl_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return 0;
|
||||
error:
|
||||
pw_impl_factory_destroy(data->this);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -540,6 +540,7 @@ int endpoint_factory_init(struct pw_impl_module *module)
|
|||
struct pw_context *context = pw_impl_module_get_context(module);
|
||||
struct pw_impl_factory *factory;
|
||||
struct factory_data *data;
|
||||
int res;
|
||||
|
||||
factory = pw_context_create_factory(context,
|
||||
"endpoint",
|
||||
|
|
@ -558,9 +559,13 @@ int endpoint_factory_init(struct pw_impl_module *module)
|
|||
|
||||
data->export.type = PW_TYPE_INTERFACE_Endpoint;
|
||||
data->export.func = pw_core_endpoint_export;
|
||||
pw_context_register_export_type(context, &data->export);
|
||||
if ((res = pw_context_register_export_type(context, &data->export)) < 0)
|
||||
goto error;
|
||||
|
||||
pw_impl_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return 0;
|
||||
error:
|
||||
pw_impl_factory_destroy(data->this);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -529,6 +529,7 @@ int session_factory_init(struct pw_impl_module *module)
|
|||
struct pw_context *context = pw_impl_module_get_context(module);
|
||||
struct pw_impl_factory *factory;
|
||||
struct factory_data *data;
|
||||
int res;
|
||||
|
||||
factory = pw_context_create_factory(context,
|
||||
"session",
|
||||
|
|
@ -547,9 +548,13 @@ int session_factory_init(struct pw_impl_module *module)
|
|||
|
||||
data->export.type = PW_TYPE_INTERFACE_Session;
|
||||
data->export.func = pw_core_session_export;
|
||||
pw_context_register_export_type(context, &data->export);
|
||||
if ((res = pw_context_register_export_type(context, &data->export)) < 0)
|
||||
goto error;
|
||||
|
||||
pw_impl_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return 0;
|
||||
error:
|
||||
pw_impl_factory_destroy(data->this);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue