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
|
|
@ -23,9 +23,24 @@
|
|||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/debug.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
} URI;
|
||||
|
||||
typedef struct {
|
||||
URI uri;
|
||||
|
||||
SpaSupport support[2];
|
||||
unsigned int n_support;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
} AppData;
|
||||
|
||||
static void
|
||||
inspect_port (SpaNode *node, SpaDirection direction, uint32_t port_id)
|
||||
|
|
@ -86,7 +101,7 @@ inspect_node (SpaNode *node)
|
|||
}
|
||||
|
||||
static void
|
||||
inspect_factory (const SpaHandleFactory *factory)
|
||||
inspect_factory (AppData *data, const SpaHandleFactory *factory)
|
||||
{
|
||||
SpaResult res;
|
||||
SpaHandle *handle;
|
||||
|
|
@ -101,7 +116,7 @@ inspect_factory (const SpaHandleFactory *factory)
|
|||
printf (" none\n");
|
||||
|
||||
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, data->support, data->n_support)) < 0) {
|
||||
printf ("can't make factory instance: %d\n", res);
|
||||
return;
|
||||
}
|
||||
|
|
@ -110,6 +125,7 @@ inspect_factory (const SpaHandleFactory *factory)
|
|||
|
||||
while (true) {
|
||||
const SpaInterfaceInfo *info;
|
||||
uint32_t interface_id;
|
||||
|
||||
if ((res = spa_handle_factory_enum_interface_info (factory, &info, &state)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END)
|
||||
|
|
@ -117,27 +133,26 @@ inspect_factory (const SpaHandleFactory *factory)
|
|||
else
|
||||
printf ("can't enumerate interfaces: %d\n", res);
|
||||
}
|
||||
printf (" interface: (%d) '%s' : '%s'\n", info->interface_id, info->name, info->description);
|
||||
printf (" interface: '%s'\n", info->uri);
|
||||
|
||||
if ((res = spa_handle_get_interface (handle, info->interface_id, &interface)) < 0) {
|
||||
interface_id = spa_id_map_get_id (data->map, info->uri);
|
||||
|
||||
if ((res = spa_handle_get_interface (handle, interface_id, &interface)) < 0) {
|
||||
printf ("can't get interface: %d\n", res);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (info->interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
inspect_node (interface);
|
||||
break;
|
||||
default:
|
||||
printf ("skipping unknown interface\n");
|
||||
break;
|
||||
}
|
||||
if (interface_id == data->uri.node)
|
||||
inspect_node (interface);
|
||||
else
|
||||
printf ("skipping unknown interface\n");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
AppData data;
|
||||
SpaResult res;
|
||||
void *handle;
|
||||
SpaEnumHandleFactoryFunc enum_func;
|
||||
|
|
@ -148,6 +163,18 @@ main (int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
data.map = spa_id_map_get_default();
|
||||
data.log = NULL;
|
||||
|
||||
data.support[0].uri = SPA_ID_MAP_URI;
|
||||
data.support[0].data = data.map;
|
||||
data.support[1].uri = SPA_LOG_URI;
|
||||
data.support[1].data = data.log;
|
||||
data.n_support = 2;
|
||||
|
||||
data.uri.node = spa_id_map_get_id (data.map, SPA_NODE_URI);
|
||||
data.uri.clock = spa_id_map_get_id (data.map, SPA_CLOCK_URI);
|
||||
|
||||
if ((handle = dlopen (argv[1], RTLD_NOW)) == NULL) {
|
||||
printf ("can't load %s\n", argv[1]);
|
||||
return -1;
|
||||
|
|
@ -165,7 +192,7 @@ main (int argc, char *argv[])
|
|||
printf ("can't enumerate factories: %d\n", res);
|
||||
break;
|
||||
}
|
||||
inspect_factory (factory);
|
||||
inspect_factory (&data, factory);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue