mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
API cleanups
Fix docs Add some more versions to interfaces Make types for the various proxy object + inline methods that does type checking and create proxys etc. Set owner client of client-nodes in the properties Pass type to bind to in create-node Don't place global id in the info structs Improve registration of marshal functions Pass more types around as ids
This commit is contained in:
parent
465f12241e
commit
1acba78234
45 changed files with 963 additions and 764 deletions
|
|
@ -31,13 +31,15 @@ struct data {
|
|||
struct pw_loop *loop;
|
||||
struct pw_core *core;
|
||||
struct pw_remote *remote;
|
||||
struct pw_proxy *registry_proxy;
|
||||
struct pw_registry_proxy *registry_proxy;
|
||||
|
||||
struct pw_listener on_info_changed;
|
||||
struct pw_listener on_state_changed;
|
||||
};
|
||||
|
||||
struct proxy_data {
|
||||
uint32_t id;
|
||||
uint32_t version;
|
||||
void *info;
|
||||
};
|
||||
|
||||
|
|
@ -61,8 +63,7 @@ static void on_info_changed(struct pw_listener *listener, struct pw_remote *remo
|
|||
struct pw_core_info *info = remote->info;
|
||||
bool print_all = true, print_mark = false;
|
||||
|
||||
printf("\tid: %u\n", info->id);
|
||||
printf("\ttype: %s\n", PW_TYPE__Core);
|
||||
printf("\ttype: %s\n", PW_TYPE_INTERFACE__Core);
|
||||
if (print_all) {
|
||||
printf("%c\tuser-name: \"%s\"\n", MARK_CHANGE(0), info->user_name);
|
||||
printf("%c\thost-name: \"%s\"\n", MARK_CHANGE(1), info->host_name);
|
||||
|
|
@ -91,8 +92,8 @@ static void module_event_info(void *object, struct pw_module_info *info)
|
|||
|
||||
info = data->info = pw_module_info_update(data->info, info);
|
||||
|
||||
printf("\tid: %u\n", info->id);
|
||||
printf("\ttype: %s\n", PW_TYPE__Module);
|
||||
printf("\tid: %d\n", data->id);
|
||||
printf("\ttype: %s (version %d)\n", PW_TYPE_INTERFACE__Module, data->version);
|
||||
if (print_all) {
|
||||
printf("%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
|
||||
printf("%c\tfilename: \"%s\"\n", MARK_CHANGE(1), info->filename);
|
||||
|
|
@ -102,6 +103,7 @@ static void module_event_info(void *object, struct pw_module_info *info)
|
|||
}
|
||||
|
||||
static const struct pw_module_events module_events = {
|
||||
PW_VERSION_MODULE_EVENTS,
|
||||
&module_event_info,
|
||||
};
|
||||
|
||||
|
|
@ -123,8 +125,8 @@ static void node_event_info(void *object, struct pw_node_info *info)
|
|||
|
||||
info = data->info = pw_node_info_update(data->info, info);
|
||||
|
||||
printf("\tid: %u\n", info->id);
|
||||
printf("\ttype: %s\n", PW_TYPE__Node);
|
||||
printf("\tid: %d\n", data->id);
|
||||
printf("\ttype: %s (version %d)\n", PW_TYPE_INTERFACE__Node, data->version);
|
||||
if (print_all) {
|
||||
int i;
|
||||
|
||||
|
|
@ -149,6 +151,7 @@ static void node_event_info(void *object, struct pw_node_info *info)
|
|||
}
|
||||
|
||||
static const struct pw_node_events node_events = {
|
||||
PW_VERSION_NODE_EVENTS,
|
||||
&node_event_info
|
||||
};
|
||||
|
||||
|
|
@ -170,14 +173,15 @@ static void client_event_info(void *object, struct pw_client_info *info)
|
|||
|
||||
info = data->info = pw_client_info_update(data->info, info);
|
||||
|
||||
printf("\tid: %u\n", info->id);
|
||||
printf("\ttype: %s\n", PW_TYPE__Client);
|
||||
printf("\tid: %d\n", data->id);
|
||||
printf("\ttype: %s (version %d)\n", PW_TYPE_INTERFACE__Client, data->version);
|
||||
if (print_all) {
|
||||
print_properties(info->props, MARK_CHANGE(0));
|
||||
}
|
||||
}
|
||||
|
||||
static const struct pw_client_events client_events = {
|
||||
PW_VERSION_CLIENT_EVENTS,
|
||||
&client_event_info
|
||||
};
|
||||
|
||||
|
|
@ -199,8 +203,8 @@ static void link_event_info(void *object, struct pw_link_info *info)
|
|||
|
||||
info = data->info = pw_link_info_update(data->info, info);
|
||||
|
||||
printf("\tid: %u\n", info->id);
|
||||
printf("\ttype: %s\n", PW_TYPE__Link);
|
||||
printf("\tid: %d\n", data->id);
|
||||
printf("\ttype: %s (version %d)\n", PW_TYPE_INTERFACE__Link, data->version);
|
||||
if (print_all) {
|
||||
printf("%c\toutput-node-id: %u\n", MARK_CHANGE(0), info->output_node_id);
|
||||
printf("%c\toutput-port-id: %u\n", MARK_CHANGE(1), info->output_port_id);
|
||||
|
|
@ -215,6 +219,7 @@ static void link_event_info(void *object, struct pw_link_info *info)
|
|||
}
|
||||
|
||||
static const struct pw_link_events link_events = {
|
||||
PW_VERSION_LINK_EVENTS,
|
||||
&link_event_info
|
||||
};
|
||||
|
||||
|
|
@ -222,21 +227,25 @@ static void
|
|||
destroy_proxy (void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = data;
|
||||
struct pw_core *core = proxy->remote->core;
|
||||
struct proxy_data *user_data = proxy->user_data;
|
||||
struct pw_core *core = proxy->remote->core;
|
||||
|
||||
if (user_data->info == NULL)
|
||||
return;
|
||||
|
||||
if (proxy->type == core->type.core) {
|
||||
pw_core_info_free (user_data->info);
|
||||
} else if (proxy->type == core->type.node) {
|
||||
}
|
||||
else if (proxy->type == core->type.node) {
|
||||
pw_node_info_free (user_data->info);
|
||||
} else if (proxy->type == core->type.module) {
|
||||
}
|
||||
else if (proxy->type == core->type.module) {
|
||||
pw_module_info_free (user_data->info);
|
||||
} else if (proxy->type == core->type.client) {
|
||||
}
|
||||
else if (proxy->type == core->type.client) {
|
||||
pw_client_info_free (user_data->info);
|
||||
} else if (proxy->type == core->type.link) {
|
||||
}
|
||||
else if (proxy->type == core->type.link) {
|
||||
pw_link_info_free (user_data->info);
|
||||
}
|
||||
user_data->info = NULL;
|
||||
|
|
@ -245,39 +254,45 @@ destroy_proxy (void *data)
|
|||
|
||||
static void registry_event_global(void *object, uint32_t id, uint32_t type, uint32_t version)
|
||||
{
|
||||
struct pw_proxy *registry_proxy = object;
|
||||
struct data *data = registry_proxy->object;
|
||||
struct pw_core *core = data->core;
|
||||
struct pw_remote *remote = registry_proxy->remote;
|
||||
struct pw_proxy *proxy = NULL;
|
||||
struct pw_proxy *proxy = object;
|
||||
struct data *data = proxy->object;
|
||||
uint32_t client_version;
|
||||
const void *implementation;
|
||||
const void *events;
|
||||
struct pw_core *core = data->core;
|
||||
struct proxy_data *pd;
|
||||
|
||||
if (type == core->type.node) {
|
||||
implementation = &node_events;
|
||||
client_version = PW_VERSION_NODE;
|
||||
if (type == core->type.node) {
|
||||
events = &node_events;
|
||||
client_version = PW_VERSION_NODE;
|
||||
}
|
||||
else if (type == core->type.module) {
|
||||
implementation = &module_events;
|
||||
client_version = PW_VERSION_MODULE;
|
||||
events = &module_events;
|
||||
client_version = PW_VERSION_MODULE;
|
||||
}
|
||||
else if (type == core->type.client) {
|
||||
implementation = &client_events;
|
||||
client_version = PW_VERSION_CLIENT;
|
||||
events = &client_events;
|
||||
client_version = PW_VERSION_CLIENT;
|
||||
}
|
||||
else if (type == core->type.link) {
|
||||
implementation = &link_events;
|
||||
client_version = PW_VERSION_LINK;
|
||||
} else
|
||||
return;
|
||||
events = &link_events;
|
||||
client_version = PW_VERSION_LINK;
|
||||
}
|
||||
else {
|
||||
printf("added:\n");
|
||||
printf("\tid: %u\n", id);
|
||||
printf("\ttype: %s (version %d)\n", spa_type_map_get_type(core->type.map, type), version);
|
||||
return;
|
||||
}
|
||||
|
||||
proxy = pw_proxy_new(remote, SPA_ID_INVALID, type, sizeof(struct proxy_data));
|
||||
proxy = pw_registry_proxy_bind(data->registry_proxy, id, type,
|
||||
client_version, sizeof(struct proxy_data), destroy_proxy);
|
||||
if (proxy == NULL)
|
||||
goto no_mem;
|
||||
|
||||
pw_proxy_set_implementation(proxy, data, client_version, implementation, destroy_proxy);
|
||||
|
||||
pw_registry_do_bind(registry_proxy, id, version, proxy->id);
|
||||
pd = proxy->user_data;
|
||||
pd->id = id;
|
||||
pd->version = version;
|
||||
pw_proxy_add_listener(proxy, proxy, events);
|
||||
|
||||
return;
|
||||
|
||||
|
|
@ -293,6 +308,7 @@ static void registry_event_global_remove(void *object, uint32_t id)
|
|||
}
|
||||
|
||||
static const struct pw_registry_events registry_events = {
|
||||
PW_VERSION_REGISTRY_EVENTS,
|
||||
registry_event_global,
|
||||
registry_event_global_remove,
|
||||
};
|
||||
|
|
@ -310,16 +326,10 @@ static void on_state_changed(struct pw_listener *listener, struct pw_remote *rem
|
|||
case PW_REMOTE_STATE_CONNECTED:
|
||||
printf("remote state: \"%s\"\n", pw_remote_state_as_string(remote->state));
|
||||
|
||||
data->registry_proxy = pw_proxy_new(data->remote,
|
||||
SPA_ID_INVALID,
|
||||
data->core->type.registry,
|
||||
0);
|
||||
pw_proxy_set_implementation(data->registry_proxy, data, PW_VERSION_REGISTRY,
|
||||
®istry_events, NULL);
|
||||
|
||||
pw_core_do_get_registry(data->remote->core_proxy, PW_VERSION_REGISTRY,
|
||||
data->registry_proxy->id);
|
||||
|
||||
data->registry_proxy = pw_core_proxy_get_registry(data->remote->core_proxy,
|
||||
PW_VERSION_REGISTRY, 0, NULL);
|
||||
pw_registry_proxy_add_listener(data->registry_proxy,
|
||||
data, ®istry_events);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue