mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Add mapper
Ger rid of static ids for interfaces and replace with something we can register dynamically Implement logger.
This commit is contained in:
parent
a68e5d5124
commit
fc4fd1424a
43 changed files with 997 additions and 360 deletions
|
|
@ -36,6 +36,10 @@
|
|||
#define PINOS_SPA_ALSA_MONITOR_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SPA_ALSA_MONITOR, PinosSpaALSAMonitorPrivate))
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _PinosSpaALSAMonitorPrivate
|
||||
{
|
||||
PinosDaemon *daemon;
|
||||
|
|
@ -43,6 +47,8 @@ struct _PinosSpaALSAMonitorPrivate
|
|||
SpaHandle *handle;
|
||||
SpaMonitor *monitor;
|
||||
|
||||
URI uri;
|
||||
|
||||
GSource *watch_source;
|
||||
|
||||
unsigned int n_poll;
|
||||
|
|
@ -61,7 +67,7 @@ enum
|
|||
G_DEFINE_TYPE (PinosSpaALSAMonitor, pinos_spa_alsa_monitor, G_TYPE_OBJECT);
|
||||
|
||||
static SpaResult
|
||||
make_handle (SpaHandle **handle, const char *lib, const char *name, const SpaDict *info)
|
||||
make_handle (PinosDaemon *daemon, SpaHandle **handle, const char *lib, const char *name, const SpaDict *info)
|
||||
{
|
||||
SpaResult res;
|
||||
void *hnd, *state = NULL;
|
||||
|
|
@ -88,7 +94,7 @@ make_handle (SpaHandle **handle, const char *lib, const char *name, const SpaDic
|
|||
continue;
|
||||
|
||||
*handle = g_malloc0 (factory->size);
|
||||
if ((res = spa_handle_factory_init (factory, *handle, info, NULL, 0)) < 0) {
|
||||
if ((res = spa_handle_factory_init (factory, *handle, info, daemon->support, daemon->n_support)) < 0) {
|
||||
g_error ("can't make factory instance: %d", res);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -110,11 +116,15 @@ add_item (PinosSpaALSAMonitor *this, SpaMonitorItem *item)
|
|||
g_debug ("alsa-monitor %p: add: \"%s\" (%s)", this, item->name, item->id);
|
||||
|
||||
handle = calloc (1, item->factory->size);
|
||||
if ((res = spa_handle_factory_init (item->factory, handle, item->info, NULL, 0)) < 0) {
|
||||
if ((res = spa_handle_factory_init (item->factory,
|
||||
handle,
|
||||
item->info,
|
||||
priv->daemon->support,
|
||||
priv->daemon->n_support)) < 0) {
|
||||
g_error ("can't make factory instance: %d", res);
|
||||
return;
|
||||
}
|
||||
if ((res = spa_handle_get_interface (handle, SPA_INTERFACE_ID_NODE, &iface)) < 0) {
|
||||
if ((res = spa_handle_get_interface (handle, priv->uri.node, &iface)) < 0) {
|
||||
g_error ("can't get MONITOR interface: %d", res);
|
||||
return;
|
||||
}
|
||||
|
|
@ -240,6 +250,8 @@ monitor_constructed (GObject * object)
|
|||
|
||||
G_OBJECT_CLASS (pinos_spa_alsa_monitor_parent_class)->constructed (object);
|
||||
|
||||
priv->uri.node = spa_id_map_get_id (priv->daemon->map, SPA_NODE_URI);
|
||||
|
||||
while (TRUE) {
|
||||
SpaMonitorItem *item;
|
||||
|
||||
|
|
@ -365,15 +377,18 @@ pinos_spa_alsa_monitor_new (PinosDaemon *daemon)
|
|||
SpaResult res;
|
||||
void *iface;
|
||||
|
||||
if ((res = make_handle (&handle,
|
||||
"build/spa/plugins/alsa/libspa-alsa.so",
|
||||
"alsa-monitor",
|
||||
NULL)) < 0) {
|
||||
if ((res = make_handle (daemon, &handle,
|
||||
"build/spa/plugins/alsa/libspa-alsa.so",
|
||||
"alsa-monitor",
|
||||
NULL)) < 0) {
|
||||
g_error ("can't create alsa-monitor: %d", res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((res = spa_handle_get_interface (handle, SPA_INTERFACE_ID_MONITOR, &iface)) < 0) {
|
||||
|
||||
if ((res = spa_handle_get_interface (handle,
|
||||
spa_id_map_get_id (daemon->map, SPA_MONITOR_URI),
|
||||
&iface)) < 0) {
|
||||
g_free (handle);
|
||||
g_error ("can't get MONITOR interface: %d", res);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ enum {
|
|||
G_DEFINE_TYPE (PinosSpaAudioTestSrc, pinos_spa_audiotestsrc, PINOS_TYPE_NODE);
|
||||
|
||||
static SpaResult
|
||||
make_node (SpaNode **node, const char *lib, const char *name)
|
||||
make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *name)
|
||||
{
|
||||
SpaHandle *handle;
|
||||
SpaResult res;
|
||||
|
|
@ -69,11 +69,17 @@ make_node (SpaNode **node, const char *lib, const char *name)
|
|||
continue;
|
||||
|
||||
handle = calloc (1, factory->size);
|
||||
if ((res = spa_handle_factory_init (factory, handle, NULL, NULL, 0)) < 0) {
|
||||
if ((res = spa_handle_factory_init (factory,
|
||||
handle,
|
||||
NULL,
|
||||
daemon->support,
|
||||
daemon->n_support)) < 0) {
|
||||
g_error ("can't make factory instance: %d", res);
|
||||
return res;
|
||||
}
|
||||
if ((res = spa_handle_get_interface (handle, SPA_INTERFACE_ID_NODE, &iface)) < 0) {
|
||||
if ((res = spa_handle_get_interface (handle,
|
||||
spa_id_map_get_id (daemon->map, SPA_NODE_URI),
|
||||
&iface)) < 0) {
|
||||
g_error ("can't get interface %d", res);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -177,7 +183,8 @@ pinos_spa_audiotestsrc_new (PinosDaemon *daemon,
|
|||
SpaNode *n;
|
||||
SpaResult res;
|
||||
|
||||
if ((res = make_node (&n,
|
||||
if ((res = make_node (daemon,
|
||||
&n,
|
||||
"build/spa/plugins/audiotestsrc/libspa-audiotestsrc.so",
|
||||
"audiotestsrc")) < 0) {
|
||||
g_error ("can't create audiotestsrc: %d", res);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@
|
|||
#define PINOS_SPA_V4L2_MONITOR_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SPA_V4L2_MONITOR, PinosSpaV4l2MonitorPrivate))
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _PinosSpaV4l2MonitorPrivate
|
||||
{
|
||||
PinosDaemon *daemon;
|
||||
|
|
@ -43,6 +47,8 @@ struct _PinosSpaV4l2MonitorPrivate
|
|||
SpaHandle *handle;
|
||||
SpaMonitor *monitor;
|
||||
|
||||
URI uri;
|
||||
|
||||
GSource *watch_source;
|
||||
|
||||
unsigned int n_poll;
|
||||
|
|
@ -61,7 +67,7 @@ enum
|
|||
G_DEFINE_TYPE (PinosSpaV4l2Monitor, pinos_spa_v4l2_monitor, G_TYPE_OBJECT);
|
||||
|
||||
static SpaResult
|
||||
make_handle (SpaHandle **handle, const char *lib, const char *name, const SpaDict *info)
|
||||
make_handle (PinosDaemon *daemon, SpaHandle **handle, const char *lib, const char *name, const SpaDict *info)
|
||||
{
|
||||
SpaResult res;
|
||||
void *hnd, *state = NULL;
|
||||
|
|
@ -88,7 +94,7 @@ make_handle (SpaHandle **handle, const char *lib, const char *name, const SpaDic
|
|||
continue;
|
||||
|
||||
*handle = g_malloc0 (factory->size);
|
||||
if ((res = spa_handle_factory_init (factory, *handle, info, NULL, 0)) < 0) {
|
||||
if ((res = spa_handle_factory_init (factory, *handle, info, daemon->support, daemon->n_support)) < 0) {
|
||||
g_error ("can't make factory instance: %d", res);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -110,12 +116,16 @@ add_item (PinosSpaV4l2Monitor *this, SpaMonitorItem *item)
|
|||
g_debug ("v4l2-monitor %p: add: \"%s\" (%s)", this, item->name, item->id);
|
||||
|
||||
handle = calloc (1, item->factory->size);
|
||||
if ((res = spa_handle_factory_init (item->factory, handle, item->info, NULL, 0)) < 0) {
|
||||
if ((res = spa_handle_factory_init (item->factory,
|
||||
handle,
|
||||
item->info,
|
||||
priv->daemon->support,
|
||||
priv->daemon->n_support)) < 0) {
|
||||
g_error ("can't make factory instance: %d", res);
|
||||
return;
|
||||
}
|
||||
if ((res = spa_handle_get_interface (handle, SPA_INTERFACE_ID_NODE, &iface)) < 0) {
|
||||
g_error ("can't get MONITOR interface: %d", res);
|
||||
if ((res = spa_handle_get_interface (handle, priv->uri.node, &iface)) < 0) {
|
||||
g_error ("can't get NODE interface: %d", res);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -240,6 +250,8 @@ monitor_constructed (GObject * object)
|
|||
|
||||
G_OBJECT_CLASS (pinos_spa_v4l2_monitor_parent_class)->constructed (object);
|
||||
|
||||
priv->uri.node = spa_id_map_get_id (priv->daemon->map, SPA_NODE_URI);
|
||||
|
||||
while (TRUE) {
|
||||
SpaMonitorItem *item;
|
||||
|
||||
|
|
@ -365,15 +377,18 @@ pinos_spa_v4l2_monitor_new (PinosDaemon *daemon)
|
|||
SpaResult res;
|
||||
void *iface;
|
||||
|
||||
if ((res = make_handle (&handle,
|
||||
"build/spa/plugins/v4l2/libspa-v4l2.so",
|
||||
"v4l2-monitor",
|
||||
NULL)) < 0) {
|
||||
if ((res = make_handle (daemon,
|
||||
&handle,
|
||||
"build/spa/plugins/v4l2/libspa-v4l2.so",
|
||||
"v4l2-monitor",
|
||||
NULL)) < 0) {
|
||||
g_error ("can't create v4l2-monitor: %d", res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((res = spa_handle_get_interface (handle, SPA_INTERFACE_ID_MONITOR, &iface)) < 0) {
|
||||
if ((res = spa_handle_get_interface (handle,
|
||||
spa_id_map_get_id (daemon->map, SPA_MONITOR_URI),
|
||||
&iface)) < 0) {
|
||||
g_free (handle);
|
||||
g_error ("can't get MONITOR interface: %d", res);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ enum {
|
|||
G_DEFINE_TYPE (PinosSpaVideoTestSrc, pinos_spa_videotestsrc, PINOS_TYPE_NODE);
|
||||
|
||||
static SpaResult
|
||||
make_node (SpaNode **node, const char *lib, const char *name)
|
||||
make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *name)
|
||||
{
|
||||
SpaHandle *handle;
|
||||
SpaResult res;
|
||||
|
|
@ -68,11 +68,13 @@ make_node (SpaNode **node, const char *lib, const char *name)
|
|||
continue;
|
||||
|
||||
handle = calloc (1, factory->size);
|
||||
if ((res = factory->init (factory, handle, NULL, NULL, 0)) < 0) {
|
||||
if ((res = factory->init (factory, handle, NULL, daemon->support, daemon->n_support)) < 0) {
|
||||
g_error ("can't make factory instance: %d", res);
|
||||
return res;
|
||||
}
|
||||
if ((res = handle->get_interface (handle, SPA_INTERFACE_ID_NODE, &iface)) < 0) {
|
||||
if ((res = handle->get_interface (handle,
|
||||
spa_id_map_get_id (daemon->map, SPA_NODE_URI),
|
||||
&iface)) < 0) {
|
||||
g_error ("can't get interface %d", res);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -148,7 +150,8 @@ pinos_spa_videotestsrc_new (PinosDaemon *daemon,
|
|||
SpaNode *n;
|
||||
SpaResult res;
|
||||
|
||||
if ((res = make_node (&n,
|
||||
if ((res = make_node (daemon,
|
||||
&n,
|
||||
"build/spa/plugins/videotestsrc/libspa-videotestsrc.so",
|
||||
"videotestsrc")) < 0) {
|
||||
g_error ("can't create videotestsrc: %d", res);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue