mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-20 06:59:58 -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
|
|
@ -228,7 +228,7 @@ pinos_client_node_init (PinosClientNode * 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;
|
||||
|
|
@ -257,11 +257,17 @@ 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;
|
||||
}
|
||||
|
|
@ -293,7 +299,8 @@ pinos_client_node_new (PinosDaemon *daemon,
|
|||
|
||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||
|
||||
if ((res = make_node (&n,
|
||||
if ((res = make_node (daemon,
|
||||
&n,
|
||||
"build/spa/plugins/remote/libspa-remote.so",
|
||||
"proxy")) < 0) {
|
||||
g_error ("can't create proxy: %d", res);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gio/gunixfdlist.h>
|
||||
|
|
@ -55,6 +56,9 @@ struct _PinosDaemonPrivate
|
|||
PinosProperties *properties;
|
||||
|
||||
GHashTable *node_factories;
|
||||
|
||||
SpaSupport support[2];
|
||||
SpaLog log;
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
@ -65,6 +69,7 @@ enum
|
|||
PROP_OBJECT_PATH,
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
handle_client_appeared (PinosClient *client, gpointer user_data)
|
||||
{
|
||||
|
|
@ -825,6 +830,43 @@ pinos_daemon_class_init (PinosDaemonClass * klass)
|
|||
|
||||
}
|
||||
|
||||
static void
|
||||
do_logv (SpaLog *log,
|
||||
SpaLogLevel level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
|
||||
{
|
||||
char text[16*1024], location[128];
|
||||
static const char *levels[] = {
|
||||
"NONE",
|
||||
"ERROR",
|
||||
"WARN",
|
||||
"INFO",
|
||||
"TRACE",
|
||||
};
|
||||
vsnprintf (text, sizeof(text), fmt, args);
|
||||
snprintf (location, sizeof(location), "%s:%i %s()", file, line, func);
|
||||
fprintf(stderr, "[%s][%s] %s", levels[level], location, text);
|
||||
}
|
||||
|
||||
static void
|
||||
do_log (SpaLog *log,
|
||||
SpaLogLevel level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
do_logv (log, level, file, line, func, fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
static void
|
||||
pinos_daemon_init (PinosDaemon * daemon)
|
||||
{
|
||||
|
|
@ -842,6 +884,23 @@ pinos_daemon_init (PinosDaemon * daemon)
|
|||
g_free,
|
||||
g_object_unref);
|
||||
priv->loop = pinos_rtloop_new();
|
||||
|
||||
priv->log.handle = NULL;
|
||||
priv->log.size = sizeof (SpaLog);
|
||||
priv->log.info = NULL;
|
||||
priv->log.level = SPA_LOG_LEVEL_INFO;
|
||||
priv->log.log = do_log;
|
||||
priv->log.logv = do_logv;
|
||||
|
||||
daemon->map = spa_id_map_get_default();
|
||||
daemon->log = &priv->log;
|
||||
|
||||
priv->support[0].uri = SPA_ID_MAP_URI;
|
||||
priv->support[0].data = daemon->map;
|
||||
priv->support[1].uri = SPA_LOG_URI;
|
||||
priv->support[1].data = daemon->log;
|
||||
daemon->support = priv->support;
|
||||
daemon->n_support = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ typedef struct _PinosDaemon PinosDaemon;
|
|||
typedef struct _PinosDaemonClass PinosDaemonClass;
|
||||
typedef struct _PinosDaemonPrivate PinosDaemonPrivate;
|
||||
|
||||
#include <spa/include/spa/plugin.h>
|
||||
#include <spa/include/spa/log.h>
|
||||
#include <spa/include/spa/id-map.h>
|
||||
#include <pinos/server/node.h>
|
||||
#include <pinos/server/node-factory.h>
|
||||
#include <pinos/client/properties.h>
|
||||
|
|
@ -49,6 +52,12 @@ typedef struct _PinosDaemonPrivate PinosDaemonPrivate;
|
|||
struct _PinosDaemon {
|
||||
GObject object;
|
||||
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaSupport *support;
|
||||
unsigned int n_support;
|
||||
|
||||
PinosDaemonPrivate *priv;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -658,7 +658,9 @@ pinos_node_set_property (GObject *_object,
|
|||
{
|
||||
void *iface;
|
||||
this->node = g_value_get_pointer (value);
|
||||
if (this->node->handle->get_interface (this->node->handle, SPA_INTERFACE_ID_CLOCK, &iface) >= 0)
|
||||
if (this->node->handle->get_interface (this->node->handle,
|
||||
spa_id_map_get_id (priv->daemon->map, SPA_CLOCK_URI),
|
||||
&iface) >= 0)
|
||||
this->clock = iface;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue