pass the global type as an id instead of string

This commit is contained in:
Wim Taymans 2017-07-11 18:41:22 +02:00
parent d1655196c3
commit f7e9e0c33a
9 changed files with 41 additions and 40 deletions

View file

@ -1,11 +1,11 @@
#load-module libpipewire-module-protocol-dbus
load-module libpipewire-module-protocol-native
load-module libpipewire-module-suspend-on-idle
#load-module libpipewire-module-spa-monitor alsa/libspa-alsa alsa-monitor alsa
load-module libpipewire-module-spa-monitor alsa/libspa-alsa alsa-monitor alsa
load-module libpipewire-module-spa-monitor v4l2/libspa-v4l2 v4l2-monitor v4l2
#load-module libpipewire-module-spa-node videotestsrc/libspa-videotestsrc videotestsrc videotestsrc media.class=Video/Source Spa:POD:Object:Props:patternType=Spa:POD:Object:Props:patternType:snow
load-module libpipewire-module-autolink
#load-module libpipewire-module-mixer
load-module libpipewire-module-mixer
load-module libpipewire-module-client-node
load-module libpipewire-module-flatpak
#load-module libpipewire-module-jack

View file

@ -319,7 +319,7 @@ static const struct pw_node_events node_events = {
&node_event_info
};
static void registry_event_global(void *object, uint32_t id, const char *type, uint32_t version)
static void registry_event_global(void *object, uint32_t id, uint32_t type, uint32_t version)
{
struct pw_proxy *registry = object;
GstPipeWireDeviceProvider *self = registry->object;
@ -327,7 +327,7 @@ static void registry_event_global(void *object, uint32_t id, const char *type, u
struct pw_core *core = remote->core;
struct pw_proxy *proxy = NULL;
if (strcmp(type, PIPEWIRE_TYPE__Node))
if (type != core->type.node)
return;
proxy = pw_proxy_new(remote, SPA_ID_INVALID, core->type.node, 0);

View file

@ -452,6 +452,8 @@ on_remote_data(struct spa_loop_utils *utils,
struct pw_connection *conn = impl->connection;
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
pw_log_error("protocol-native %p: got connection error", impl);
pw_remote_destroy(this);
return;
}

View file

@ -522,7 +522,7 @@ static bool core_demarshal_update_types_server(void *object, void *data, size_t
return true;
}
static void registry_marshal_global(void *object, uint32_t id, const char *type, uint32_t version)
static void registry_marshal_global(void *object, uint32_t id, uint32_t type, uint32_t version)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
@ -533,7 +533,7 @@ static void registry_marshal_global(void *object, uint32_t id, const char *type,
spa_pod_builder_struct(b, &f,
SPA_POD_TYPE_INT, id,
SPA_POD_TYPE_STRING, type,
SPA_POD_TYPE_ID, type,
SPA_POD_TYPE_INT, version);
pw_connection_end_write(connection, b);
@ -829,13 +829,13 @@ static bool registry_demarshal_global(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_iter it;
uint32_t id, version;
const char *type;
uint32_t id, type, version;
if (!spa_pod_iter_struct(&it, data, size) ||
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
!spa_pod_iter_get(&it,
SPA_POD_TYPE_INT, &id,
SPA_POD_TYPE_STRING, &type,
SPA_POD_TYPE_ID, &type,
SPA_POD_TYPE_INT, &version, 0))
return false;

View file

@ -133,8 +133,7 @@ static void core_get_registry(void *object, uint32_t new_id)
if (pw_global_is_visible(global, client))
pw_registry_notify_global(registry_resource,
global->id,
spa_type_map_get_type(this->type.map,
global->type),
global->type,
global->version);
}
@ -400,7 +399,6 @@ pw_core_add_global(struct pw_core *core,
struct global_impl *impl;
struct pw_global *this;
struct pw_resource *registry;
const char *type_name;
impl = calloc(1, sizeof(struct global_impl));
if (impl == NULL)
@ -423,12 +421,11 @@ pw_core_add_global(struct pw_core *core,
spa_list_insert(core->global_list.prev, &this->link);
pw_signal_emit(&core->global_added, core, this);
type_name = spa_type_map_get_type(core->type.map, this->type);
pw_log_debug("global %p: new %u %s, owner %p", this, this->id, type_name, owner);
pw_log_debug("global %p: new %u %d, owner %p", this, this->id, this->type, owner);
spa_list_for_each(registry, &core->registry_resource_list, link)
if (pw_global_is_visible(this, registry->client))
pw_registry_notify_global(registry, this->id, type_name, this->version);
pw_registry_notify_global(registry, this->id, this->type, this->version);
return true;
}

View file

@ -256,7 +256,7 @@ struct pw_registry_events {
* \param type the type of the object
* \param version the version of the object
*/
void (*global) (void *object, uint32_t id, const char *type, uint32_t version);
void (*global) (void *object, uint32_t id, uint32_t type, uint32_t version);
/**
* Notify of a global object removal
*

View file

@ -206,7 +206,6 @@ struct pw_remote *pw_remote_new(struct pw_core *core,
void pw_remote_destroy(struct pw_remote *remote)
{
struct remote *impl = SPA_CONTAINER_OF(remote, struct remote, this);
struct pw_proxy *proxy, *t2;
pw_log_debug("remote %p: destroy", remote);
pw_signal_emit(&remote->destroy_signal, remote);
@ -216,17 +215,8 @@ void pw_remote_destroy(struct pw_remote *remote)
remote->conn->destroy(remote->conn);
spa_list_for_each_safe(proxy, t2, &remote->proxy_list, link)
pw_proxy_destroy(proxy);
pw_map_clear(&remote->objects);
pw_map_clear(&remote->types);
spa_list_remove(&remote->link);
if (remote->info)
pw_core_info_free (remote->info);
if (remote->properties)
pw_properties_free(remote->properties);
free(remote->error);
@ -283,11 +273,24 @@ int pw_remote_connect_fd(struct pw_remote *remote, int fd)
void pw_remote_disconnect(struct pw_remote *remote)
{
struct pw_proxy *proxy, *t2;
pw_log_debug("remote %p: disconnect", remote);
remote->conn->disconnect(remote->conn);
if (remote->core_proxy)
pw_proxy_destroy(remote->core_proxy);
spa_list_for_each_safe(proxy, t2, &remote->proxy_list, link)
pw_proxy_destroy(proxy);
remote->core_proxy = NULL;
pw_map_clear(&remote->objects);
pw_map_clear(&remote->types);
remote->n_types = 0;
if (remote->info) {
pw_core_info_free (remote->info);
remote->info = NULL;
}
remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL);
}

View file

@ -137,7 +137,7 @@ struct pw_remote {
struct pw_map types; /**< client types */
struct spa_list proxy_list; /**< list of \ref pw_proxy objects */
struct spa_list stream_list; /**< list of \ref pw_proxy objects */
struct spa_list stream_list; /**< list of \ref pw_stream objects */
struct pw_protocol *protocol; /**< the protocol in use */
void *protocol_private; /**< private data for the protocol */

View file

@ -241,36 +241,35 @@ destroy_proxy (void *data)
}
static void registry_event_global(void *object, uint32_t id, const char *type, uint32_t version)
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;
uint32_t proxy_type, client_version;
uint32_t client_version;
const void *implementation;
if (!strcmp(type, PIPEWIRE_TYPE__Node)) {
proxy_type = core->type.node;
if (type == core->type.node) {
implementation = &node_events;
client_version = PW_VERSION_NODE;
} else if (!strcmp(type, PIPEWIRE_TYPE__Module)) {
proxy_type = core->type.module;
}
else if (type == core->type.module) {
implementation = &module_events;
client_version = PW_VERSION_MODULE;
} else if (!strcmp(type, PIPEWIRE_TYPE__Client)) {
proxy_type = core->type.client;
}
else if (type == core->type.client) {
implementation = &client_events;
client_version = PW_VERSION_CLIENT;
} else if (!strcmp(type, PIPEWIRE_TYPE__Link)) {
proxy_type = core->type.link;
}
else if (type == core->type.link) {
implementation = &link_events;
client_version = PW_VERSION_LINK;
} else
return;
proxy = pw_proxy_new(remote, SPA_ID_INVALID, proxy_type, sizeof(struct proxy_data));
proxy = pw_proxy_new(remote, SPA_ID_INVALID, type, sizeof(struct proxy_data));
if (proxy == NULL)
goto no_mem;