mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -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
|
|
@ -107,7 +107,9 @@ static struct node *create_node(struct object *obj, uint32_t id,
|
|||
{
|
||||
struct node *node;
|
||||
struct impl *impl = obj->impl;
|
||||
struct pw_core *core = impl->core;
|
||||
const struct spa_support *support;
|
||||
const char *lib;
|
||||
uint32_t n_support;
|
||||
struct spa_handle *handle;
|
||||
int res;
|
||||
|
|
@ -118,26 +120,31 @@ static struct node *create_node(struct object *obj, uint32_t id,
|
|||
if (info->type != SPA_TYPE_INTERFACE_Node)
|
||||
return NULL;
|
||||
|
||||
support = pw_core_get_support(impl->core, &n_support);
|
||||
support = pw_core_get_support(core, &n_support);
|
||||
|
||||
handle = calloc(1, spa_handle_factory_get_size(info->factory, NULL));
|
||||
if ((res = spa_handle_factory_init(info->factory,
|
||||
handle,
|
||||
info->props,
|
||||
support,
|
||||
n_support)) < 0) {
|
||||
pw_log_error("can't make factory instance: %d", res);
|
||||
goto free_handle;
|
||||
lib = pw_core_find_spa_lib(core, info->factory_name);
|
||||
if (lib == NULL) {
|
||||
pw_log_error("can't find spa lib for factory %s", info->factory_name);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
handle = pw_load_spa_handle(lib,
|
||||
info->factory_name,
|
||||
info->props,
|
||||
n_support, support);
|
||||
if (handle == NULL) {
|
||||
pw_log_error("can't make factory instance: %m");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
|
||||
pw_log_error("can't get %d interface: %d", info->type, res);
|
||||
goto clean_handle;
|
||||
goto unload_handle;
|
||||
}
|
||||
|
||||
node = calloc(1, sizeof(*node));
|
||||
if (node == NULL)
|
||||
goto clean_handle;
|
||||
goto unload_handle;
|
||||
|
||||
node->impl = impl;
|
||||
node->object = obj;
|
||||
|
|
@ -157,10 +164,9 @@ static struct node *create_node(struct object *obj, uint32_t id,
|
|||
|
||||
clean_node:
|
||||
free(node);
|
||||
clean_handle:
|
||||
spa_handle_clear(handle);
|
||||
free_handle:
|
||||
free(handle);
|
||||
unload_handle:
|
||||
pw_unload_spa_handle(handle);
|
||||
exit:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -221,10 +227,12 @@ static void update_object(struct impl *impl, struct object *obj,
|
|||
static struct object *create_object(struct impl *impl, uint32_t id,
|
||||
const struct spa_monitor_object_info *info)
|
||||
{
|
||||
struct pw_core *core = impl->core;
|
||||
struct object *obj;
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
struct spa_handle *handle;
|
||||
const char *lib;
|
||||
int res;
|
||||
void *iface;
|
||||
|
||||
|
|
@ -233,26 +241,31 @@ static struct object *create_object(struct impl *impl, uint32_t id,
|
|||
if (info->type != SPA_TYPE_INTERFACE_Device)
|
||||
return NULL;
|
||||
|
||||
support = pw_core_get_support(impl->core, &n_support);
|
||||
support = pw_core_get_support(core, &n_support);
|
||||
|
||||
handle = calloc(1, spa_handle_factory_get_size(info->factory, NULL));
|
||||
if ((res = spa_handle_factory_init(info->factory,
|
||||
handle,
|
||||
info->props,
|
||||
support,
|
||||
n_support)) < 0) {
|
||||
pw_log_error("can't make factory instance: %d", res);
|
||||
goto free_handle;
|
||||
lib = pw_core_find_spa_lib(core, info->factory_name);
|
||||
if (lib == NULL) {
|
||||
pw_log_error("can't find spa lib for factory %s", info->factory_name);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
handle = pw_load_spa_handle(lib,
|
||||
info->factory_name,
|
||||
info->props,
|
||||
n_support, support);
|
||||
if (handle == NULL) {
|
||||
pw_log_error("can't make factory instance: %m");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
|
||||
pw_log_error("can't get %d interface: %d", info->type, res);
|
||||
goto clean_handle;
|
||||
goto unload_handle;
|
||||
}
|
||||
|
||||
obj = calloc(1, sizeof(*obj));
|
||||
if (obj == NULL)
|
||||
goto clean_handle;
|
||||
goto unload_handle;
|
||||
|
||||
obj->impl = impl;
|
||||
obj->id = id;
|
||||
|
|
@ -276,10 +289,9 @@ static struct object *create_object(struct impl *impl, uint32_t id,
|
|||
|
||||
clean_object:
|
||||
free(obj);
|
||||
clean_handle:
|
||||
spa_handle_clear(handle);
|
||||
free_handle:
|
||||
free(handle);
|
||||
unload_handle:
|
||||
pw_unload_spa_handle(handle);
|
||||
exit:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "usage: %s <library> <factory>\n\n"
|
||||
"\texample: %s v4l2/libspa-v4l2 v4l2-device\n\n",
|
||||
"\texample: %s v4l2/libspa-v4l2 api.v4l2.device\n\n",
|
||||
argv[0], argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "usage: %s <library> <factory> [path]\n\n"
|
||||
"\texample: %s v4l2/libspa-v4l2 v4l2-source\n\n",
|
||||
"\texample: %s v4l2/libspa-v4l2 api.v4l2.source\n\n",
|
||||
argv[0], argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ static const struct spa_node_methods impl_node = {
|
|||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static void make_nodes(struct data *data)
|
||||
static int make_nodes(struct data *data)
|
||||
{
|
||||
struct pw_factory *factory;
|
||||
struct pw_properties *props;
|
||||
|
|
@ -348,13 +348,16 @@ static void make_nodes(struct data *data)
|
|||
|
||||
factory = pw_core_find_factory(data->core, "spa-node-factory");
|
||||
props = pw_properties_new("spa.library.name", "v4l2/libspa-v4l2",
|
||||
"spa.factory.name", "v4l2-source", NULL);
|
||||
"spa.factory.name", "api.v4l2.source", NULL);
|
||||
data->v4l2 = pw_factory_create_object(factory,
|
||||
NULL,
|
||||
PW_TYPE_INTERFACE_Node,
|
||||
PW_VERSION_NODE_PROXY,
|
||||
props,
|
||||
SPA_ID_INVALID);
|
||||
if (data->v4l2 == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
data->link = pw_link_new(data->core,
|
||||
pw_node_find_port(data->v4l2, PW_DIRECTION_OUTPUT, 0),
|
||||
pw_node_find_port(data->node, PW_DIRECTION_INPUT, 0),
|
||||
|
|
@ -365,6 +368,8 @@ static void make_nodes(struct data *data)
|
|||
|
||||
pw_node_set_active(data->node, true);
|
||||
pw_node_set_active(data->v4l2, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue