names: add standard factory name definitions

Define a set of standard factory names and document what they
contain. This makes it possible to change the implementation by
mapping the factory-name to a different shared library.
This commit is contained in:
Wim Taymans 2019-06-21 13:31:34 +02:00
parent 4494f9c7c9
commit 6720ded529
40 changed files with 188 additions and 55 deletions

View file

@ -3,6 +3,7 @@
#set-prop library.name.system support/libspa-support
#set-prop core.data-loop.library.name.system support/libspa-support
add-spa-lib audio.convert* audioconvert/libspa-audioconvert
add-spa-lib api.alsa.* alsa/libspa-alsa
add-spa-lib api.v4l2.* v4l2/libspa-v4l2
add-spa-lib api.bluez5.* bluez5/libspa-bluez5

View file

@ -32,6 +32,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -314,7 +315,7 @@ static int start_monitor(struct impl *impl)
int res;
void *iface;
handle = pw_core_load_spa_handle(impl->core, "api.bluez5.monitor", NULL);
handle = pw_core_load_spa_handle(impl->core, SPA_NAME_API_BLUEZ5_MONITOR, NULL);
if (handle == NULL) {
res = -errno;
goto out;

View file

@ -37,6 +37,7 @@
#include <spa/node/io.h>
#include <spa/node/utils.h>
#include <spa/debug/format.h>
#include <spa/utils/names.h>
#include <pipewire/pipewire.h>
@ -348,7 +349,7 @@ static int make_nodes(struct data *data)
factory = pw_core_find_factory(data->core, "spa-node-factory");
props = pw_properties_new(SPA_KEY_LIBRARY_NAME, "v4l2/libspa-v4l2",
SPA_KEY_FACTORY_NAME, "api.v4l2.source", NULL);
SPA_KEY_FACTORY_NAME, SPA_NAME_API_V4L2_SOURCE, NULL);
data->v4l2 = pw_factory_create_object(factory,
NULL,
PW_TYPE_INTERFACE_Node,

View file

@ -32,6 +32,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/param/audio/format-utils.h>
#include <spa/utils/type-info.h>
#include <spa/param/audio/type-info.h>
@ -262,7 +263,7 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
{
struct pw_node *node;
struct node *n;
const char *api, *alias, *str, *factory;
const char *api, *alias, *str, *mode;
char node_name[128];
enum pw_direction direction;
uint32_t max_buffer_size;
@ -307,16 +308,16 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
if (direction == PW_DIRECTION_OUTPUT) {
pw_properties_set(props, "merger.monitor", "1");
factory = "merge";
mode = "merge";
} else {
factory = "split";
mode = "split";
}
pw_properties_set(props, "factory.mode", factory);
factory = "audioconvert";
pw_properties_set(props, "factory.mode", mode);
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
node = pw_spa_node_load(core, NULL, NULL,
factory,
SPA_NAME_AUDIO_CONVERT,
node_name,
PW_SPA_NODE_FLAG_ACTIVATE | PW_SPA_NODE_FLAG_NO_REGISTER,
pw_properties_copy(props),

View file

@ -28,6 +28,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -931,7 +932,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_floatmix_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_MIXER,
NULL,
impl_get_size,
impl_init,

View file

@ -35,6 +35,7 @@
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/utils/names.h>
#include <spa/buffer/alloc.h>
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
@ -1059,7 +1060,7 @@ static void client_node_initialized(void *data)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
if ((impl->handle = pw_core_load_spa_handle(impl->core,
"audioconvert",
SPA_NAME_AUDIO_CONVERT,
&SPA_DICT_INIT(items, n_items))) == NULL)
return;

View file

@ -31,6 +31,7 @@
#include <spa/support/dbus.h>
#include <spa/node/utils.h>
#include <spa/utils/names.h>
#include <spa/debug/format.h>
#include <spa/debug/types.h>
@ -516,7 +517,10 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop,
if (lib == NULL)
lib = "support/libspa-dbus";
impl->dbus_handle = pw_load_spa_handle(lib, "dbus", NULL, n_support, this->support);
impl->dbus_handle = pw_load_spa_handle(lib,
SPA_NAME_SUPPORT_DBUS, NULL,
n_support, this->support);
if (impl->dbus_handle == NULL ||
(res = spa_handle_get_interface(impl->dbus_handle,
SPA_TYPE_INTERFACE_DBus, &dbus_iface)) < 0) {

View file

@ -25,6 +25,7 @@
#include <stdio.h>
#include <spa/support/loop.h>
#include <spa/utils/names.h>
#include <pipewire/pipewire.h>
#include <pipewire/loop.h>
@ -76,12 +77,12 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
lib = NULL;
impl->system_handle = pw_load_spa_handle(lib,
"system",
SPA_NAME_SUPPORT_SYSTEM,
properties ? &properties->dict : NULL,
n_support, support);
if (impl->system_handle == NULL) {
res = -errno;
pw_log_error("can't make system handle: %m");
pw_log_error("can't make "SPA_NAME_SUPPORT_SYSTEM" handle: %m");
goto error_free;
}
@ -101,12 +102,12 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
lib = NULL;
impl->loop_handle = pw_load_spa_handle(lib,
"loop",
SPA_NAME_SUPPORT_LOOP,
properties ? &properties->dict : NULL,
n_support, support);
if (impl->loop_handle == NULL) {
res = -errno;
pw_log_error("can't make loop handle: %m");
pw_log_error("can't make "SPA_NAME_SUPPORT_LOOP" handle: %m");
goto error_unload_system;
}

View file

@ -34,6 +34,7 @@
#include <errno.h>
#include <dlfcn.h>
#include <spa/utils/names.h>
#include <spa/support/cpu.h>
#include "pipewire.h"
@ -376,7 +377,7 @@ void pw_init(int *argc, char **argv[])
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_LEVEL, level);
info = SPA_DICT_INIT(items, n_items);
log = add_interface(support, "logger", SPA_TYPE_INTERFACE_Log, &info);
log = add_interface(support, SPA_NAME_SUPPORT_LOG, SPA_TYPE_INTERFACE_Log, &info);
if (log)
pw_log_set(log);
@ -385,7 +386,7 @@ void pw_init(int *argc, char **argv[])
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_CPU_FORCE, str);
info = SPA_DICT_INIT(items, n_items);
add_interface(support, "cpu", SPA_TYPE_INTERFACE_CPU, &info);
add_interface(support, SPA_NAME_SUPPORT_CPU, SPA_TYPE_INTERFACE_CPU, &info);
pw_log_info("version %s", pw_get_library_version());
}