mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
monitor: return factory_name in the object_info
Pass a factory_name in the object_info of monitor and device. Restructure the factory name to mean something functionaly. With the factory to library mapping this then means that the implementation of certain factories can be configured in the config file.
This commit is contained in:
parent
89a86db0c4
commit
1d1f035e78
26 changed files with 218 additions and 168 deletions
|
|
@ -72,8 +72,7 @@ static void device_free(void *data)
|
|||
struct monitor_object *obj = data;
|
||||
spa_hook_remove(&obj->object_listener);
|
||||
spa_list_remove(&obj->link);
|
||||
spa_handle_clear(obj->handle);
|
||||
free(obj->handle);
|
||||
pw_unload_spa_handle(obj->handle);
|
||||
free(obj);
|
||||
}
|
||||
|
||||
|
|
@ -86,10 +85,11 @@ static struct monitor_object *add_object(struct pw_spa_monitor *this, uint32_t i
|
|||
const struct spa_monitor_object_info *info, uint64_t now)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
struct pw_core *core = impl->core;
|
||||
int res;
|
||||
struct spa_handle *handle;
|
||||
struct monitor_object *obj;
|
||||
const char *name, *str;
|
||||
const char *name, *str, *lib;
|
||||
void *iface;
|
||||
struct pw_properties *props = NULL;
|
||||
const struct spa_support *support;
|
||||
|
|
@ -111,23 +111,25 @@ static struct monitor_object *add_object(struct pw_spa_monitor *this, uint32_t i
|
|||
if (now != 0 && pw_properties_get(props, PW_KEY_DEVICE_PLUGGED) == NULL)
|
||||
pw_properties_setf(props, PW_KEY_DEVICE_PLUGGED, "%"PRIu64, now);
|
||||
|
||||
support = pw_core_get_support(impl->core, &n_support);
|
||||
lib = pw_core_find_spa_lib(core, info->factory_name);
|
||||
if (lib == NULL) {
|
||||
pw_log_warn("monitor %p: unknown library for %s",
|
||||
this, info->factory_name);
|
||||
goto error_free_props;
|
||||
}
|
||||
|
||||
handle = calloc(1, spa_handle_factory_get_size(info->factory, NULL));
|
||||
if ((res = spa_handle_factory_init(info->factory,
|
||||
handle,
|
||||
&props->dict,
|
||||
support,
|
||||
n_support)) < 0) {
|
||||
pw_properties_free(props);
|
||||
pw_log_error("can't make factory instance: %d", res);
|
||||
return NULL;
|
||||
support = pw_core_get_support(core, &n_support);
|
||||
|
||||
handle = pw_load_spa_handle(lib, info->factory_name,
|
||||
&props->dict, n_support, support);
|
||||
if (handle == NULL) {
|
||||
pw_log_error("can't make factory instance: %m");
|
||||
goto error_free_props;
|
||||
}
|
||||
|
||||
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
|
||||
pw_log_error("can't get %d interface: %d", info->type, res);
|
||||
pw_properties_free(props);
|
||||
return NULL;
|
||||
goto error_free_handle;
|
||||
}
|
||||
|
||||
obj = calloc(1, sizeof(struct monitor_object));
|
||||
|
|
@ -140,7 +142,7 @@ static struct monitor_object *add_object(struct pw_spa_monitor *this, uint32_t i
|
|||
case SPA_TYPE_INTERFACE_Device:
|
||||
{
|
||||
struct pw_device *device;
|
||||
device = pw_spa_device_new(impl->core, NULL, impl->parent, name,
|
||||
device = pw_spa_device_new(core, NULL, impl->parent, name,
|
||||
0, iface, handle, props, 0);
|
||||
pw_device_add_listener(device, &obj->object_listener,
|
||||
&device_events, obj);
|
||||
|
|
@ -149,14 +151,21 @@ static struct monitor_object *add_object(struct pw_spa_monitor *this, uint32_t i
|
|||
}
|
||||
default:
|
||||
pw_log_error("interface %d not implemented", obj->type);
|
||||
free(obj->name);
|
||||
free(obj);
|
||||
return NULL;
|
||||
goto error_free_object;
|
||||
}
|
||||
|
||||
spa_list_append(&impl->item_list, &obj->link);
|
||||
|
||||
return obj;
|
||||
|
||||
error_free_object:
|
||||
free(obj->name);
|
||||
free(obj);
|
||||
error_free_handle:
|
||||
pw_unload_spa_handle(handle);
|
||||
error_free_props:
|
||||
pw_properties_free(props);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct monitor_object *find_object(struct pw_spa_monitor *this, uint32_t id)
|
||||
|
|
@ -254,12 +263,13 @@ static const struct spa_monitor_callbacks callbacks = {
|
|||
};
|
||||
|
||||
struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
||||
struct pw_global *parent,
|
||||
const char *dir,
|
||||
const char *lib,
|
||||
const char *factory_name,
|
||||
const char *system_name,
|
||||
size_t user_data_size)
|
||||
struct pw_global *parent,
|
||||
const char *dir,
|
||||
const char *lib,
|
||||
const char *factory_name,
|
||||
const char *system_name,
|
||||
struct pw_properties *properties,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct impl *impl;
|
||||
struct pw_spa_monitor *this;
|
||||
|
|
@ -276,7 +286,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
|
||||
handle = pw_load_spa_handle(lib,
|
||||
factory_name,
|
||||
NULL,
|
||||
properties ? &properties->dict : NULL,
|
||||
n_support, support);
|
||||
if (handle == NULL)
|
||||
goto no_mem;
|
||||
|
|
@ -296,6 +306,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
this->factory_name = strdup(factory_name);
|
||||
this->system_name = strdup(system_name);
|
||||
this->handle = handle;
|
||||
this->properties = properties;
|
||||
|
||||
if (user_data_size > 0)
|
||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||
|
|
@ -330,6 +341,7 @@ void pw_spa_monitor_destroy(struct pw_spa_monitor *monitor)
|
|||
free(monitor->lib);
|
||||
free(monitor->factory_name);
|
||||
free(monitor->system_name);
|
||||
|
||||
if (monitor->properties)
|
||||
pw_properties_free(monitor->properties);
|
||||
free(impl);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue