mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Make interface types a string
This is more in line with wayland and it allows us to create new interfaces in modules without having to add anything to the type enum. It also removes some lookups to map type_id to readable name in debug.
This commit is contained in:
parent
9657486a81
commit
f391353c7f
123 changed files with 791 additions and 1251 deletions
|
|
@ -195,7 +195,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
|||
goto exit;
|
||||
}
|
||||
obj = sm_media_session_find_object(impl->session, atoi(str));
|
||||
if (obj == NULL || obj->type != PW_TYPE_INTERFACE_Endpoint) {
|
||||
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) !=0) {
|
||||
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
|
||||
res = -EINVAL;
|
||||
goto exit;
|
||||
|
|
@ -707,15 +707,11 @@ static void session_create(void *data, struct sm_object *object)
|
|||
struct impl *impl = data;
|
||||
int res;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Device:
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0)
|
||||
res = handle_device(impl, object);
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
pw_log_warn(NAME" %p: can't handle global %d: %s", impl,
|
||||
object->id, spa_strerror(res));
|
||||
|
|
@ -726,16 +722,10 @@ static void session_remove(void *data, struct sm_object *object)
|
|||
{
|
||||
struct impl *impl = data;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Device:
|
||||
{
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) {
|
||||
struct device *device;
|
||||
if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL)
|
||||
destroy_device(impl, device);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <spa/monitor/device.h>
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/keys.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/names.h>
|
||||
#include <spa/utils/keys.h>
|
||||
|
|
@ -147,7 +148,7 @@ static struct node *alsa_create_node(struct device *device, uint32_t id,
|
|||
|
||||
pw_log_debug("new node %u", id);
|
||||
|
||||
if (info->type != SPA_TYPE_INTERFACE_Node) {
|
||||
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -570,7 +571,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
|
|||
|
||||
pw_log_debug("new device %u", id);
|
||||
|
||||
if (info->type != SPA_TYPE_INTERFACE_Device) {
|
||||
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -585,7 +586,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
|
|||
}
|
||||
|
||||
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
|
||||
pw_log_error("can't get %d interface: %d", info->type, res);
|
||||
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
|
||||
goto unload_handle;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/names.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/param/props.h>
|
||||
#include <spa/debug/dict.h>
|
||||
|
|
@ -115,7 +116,7 @@ static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_
|
|||
|
||||
pw_log_debug("new node %u", id);
|
||||
|
||||
if (info->type != SPA_TYPE_INTERFACE_Node) {
|
||||
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -247,7 +248,7 @@ static struct bluez5_object *bluez5_create_object(struct impl *impl, uint32_t id
|
|||
|
||||
pw_log_debug("new object %u", id);
|
||||
|
||||
if (info->type != SPA_TYPE_INTERFACE_Device) {
|
||||
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -262,7 +263,7 @@ static struct bluez5_object *bluez5_create_object(struct impl *impl, uint32_t id
|
|||
}
|
||||
|
||||
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
|
||||
pw_log_error("can't get %d interface: %d", info->type, res);
|
||||
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
|
||||
goto unload_handle;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ struct link {
|
|||
};
|
||||
|
||||
struct object_info {
|
||||
uint32_t type;
|
||||
const char *type;
|
||||
uint32_t version;
|
||||
const void *events;
|
||||
size_t size;
|
||||
|
|
@ -387,6 +387,7 @@ static void device_destroy(void *object)
|
|||
|
||||
if (device->info)
|
||||
pw_device_info_free(device->info);
|
||||
device->info = NULL;
|
||||
}
|
||||
|
||||
static const struct object_info device_info = {
|
||||
|
|
@ -920,7 +921,10 @@ destroy_proxy(void *data)
|
|||
if (obj->destroy)
|
||||
obj->destroy(obj);
|
||||
|
||||
pw_properties_free(obj->props);
|
||||
if (obj->props)
|
||||
pw_properties_free(obj->props);
|
||||
obj->props = NULL;
|
||||
|
||||
spa_list_consume(d, &obj->data, link) {
|
||||
spa_list_remove(&d->link);
|
||||
free(d);
|
||||
|
|
@ -967,41 +971,31 @@ int sm_object_sync_update(struct sm_object *obj)
|
|||
return obj->pending;
|
||||
}
|
||||
|
||||
static const struct object_info *get_object_info(struct impl *impl, uint32_t type)
|
||||
static const struct object_info *get_object_info(struct impl *impl, const char *type)
|
||||
{
|
||||
const struct object_info *info;
|
||||
switch (type) {
|
||||
case PW_TYPE_INTERFACE_Client:
|
||||
|
||||
if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0)
|
||||
info = &client_info;
|
||||
break;
|
||||
case SPA_TYPE_INTERFACE_Device:
|
||||
else if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0)
|
||||
info = &spa_device_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_Device:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0)
|
||||
info = &device_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_Node:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0)
|
||||
info = &node_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_Port:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0)
|
||||
info = &port_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_Session:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_Session) == 0)
|
||||
info = &session_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_Endpoint:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_Endpoint) == 0)
|
||||
info = &endpoint_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_EndpointStream:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_EndpointStream) == 0)
|
||||
info = &endpoint_stream_info;
|
||||
break;
|
||||
case PW_TYPE_INTERFACE_EndpointLink:
|
||||
else if (strcmp(type, PW_TYPE_INTERFACE_EndpointLink) == 0)
|
||||
info = &endpoint_link_info;
|
||||
break;
|
||||
default:
|
||||
else
|
||||
info = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
@ -1041,7 +1035,7 @@ static struct sm_object *
|
|||
create_object(struct impl *impl, struct pw_proxy *proxy,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
uint32_t type;
|
||||
const char *type;
|
||||
const struct object_info *info;
|
||||
struct sm_object *obj;
|
||||
|
||||
|
|
@ -1049,7 +1043,7 @@ create_object(struct impl *impl, struct pw_proxy *proxy,
|
|||
|
||||
info = get_object_info(impl, type);
|
||||
if (info == NULL) {
|
||||
pw_log_error(NAME" %p: unknown object type %d", impl, type);
|
||||
pw_log_error(NAME" %p: unknown object type %s", impl, type);
|
||||
errno = ENOTSUP;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1062,7 +1056,7 @@ create_object(struct impl *impl, struct pw_proxy *proxy,
|
|||
|
||||
static struct sm_object *
|
||||
bind_object(struct impl *impl, const struct object_info *info, uint32_t id,
|
||||
uint32_t permissions, uint32_t type, uint32_t version,
|
||||
uint32_t permissions, const char *type, uint32_t version,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
int res;
|
||||
|
|
@ -1090,15 +1084,15 @@ error:
|
|||
static int
|
||||
update_object(struct impl *impl, const struct object_info *info,
|
||||
struct sm_object *obj, uint32_t id,
|
||||
uint32_t permissions, uint32_t type, uint32_t version,
|
||||
uint32_t permissions, const char *type, uint32_t version,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
pw_properties_update(obj->props, props);
|
||||
|
||||
if (obj->type == type)
|
||||
if (strcmp(obj->type, type) == 0)
|
||||
return 0;
|
||||
|
||||
pw_log_debug(NAME" %p: update type:%d -> type:%d", impl, obj->type, type);
|
||||
pw_log_debug(NAME" %p: update type:%s -> type:%s", impl, obj->type, type);
|
||||
obj->handle = obj->proxy;
|
||||
spa_hook_remove(&obj->proxy_listener);
|
||||
pw_proxy_add_listener(obj->handle, &obj->handle_listener, &proxy_events, obj);
|
||||
|
|
@ -1108,7 +1102,7 @@ update_object(struct impl *impl, const struct object_info *info,
|
|||
|
||||
obj->proxy = pw_registry_bind(impl->registry,
|
||||
id, info->type, info->version, 0);
|
||||
obj->type = type;
|
||||
obj->type = info->type;
|
||||
|
||||
pw_proxy_add_listener(obj->proxy, &obj->proxy_listener, &proxy_events, obj);
|
||||
if (info->events)
|
||||
|
|
@ -1123,15 +1117,14 @@ update_object(struct impl *impl, const struct object_info *info,
|
|||
|
||||
static void
|
||||
registry_global(void *data, uint32_t id,
|
||||
uint32_t permissions, uint32_t type, uint32_t version,
|
||||
uint32_t permissions, const char *type, uint32_t version,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct sm_object *obj;
|
||||
const struct object_info *info;
|
||||
|
||||
pw_log_debug(NAME " %p: new global '%d' %s/%d", impl, id,
|
||||
spa_debug_type_find_name(pw_type_info(), type), version);
|
||||
pw_log_debug(NAME " %p: new global '%d' %s/%d", impl, id, type, version);
|
||||
|
||||
info = get_object_info(impl, type);
|
||||
if (info == NULL)
|
||||
|
|
@ -1141,7 +1134,7 @@ registry_global(void *data, uint32_t id,
|
|||
if (obj == NULL) {
|
||||
bind_object(impl, info, id, permissions, type, version, props);
|
||||
} else {
|
||||
pw_log_debug(NAME " %p: our object %d appeared %d/%d",
|
||||
pw_log_debug(NAME " %p: our object %d appeared %s/%s",
|
||||
impl, id, obj->type, type);
|
||||
update_object(impl, info, obj, id, permissions, type, version, props);
|
||||
}
|
||||
|
|
@ -1259,7 +1252,7 @@ static const struct pw_registry_events registry_events = {
|
|||
};
|
||||
|
||||
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
|
||||
uint32_t type, const struct spa_dict *props,
|
||||
const char *type, const struct spa_dict *props,
|
||||
void *object, size_t user_data_size)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(sess, struct impl, this);
|
||||
|
|
@ -1285,7 +1278,7 @@ struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
|
|||
}
|
||||
|
||||
struct pw_proxy *sm_media_session_create_object(struct sm_media_session *sess,
|
||||
const char *factory_name, uint32_t type, uint32_t version,
|
||||
const char *factory_name, const char *type, uint32_t version,
|
||||
const struct spa_dict *props, size_t user_data_size)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(sess, struct impl, this);
|
||||
|
|
@ -1431,36 +1424,36 @@ int sm_media_session_create_links(struct sm_media_session *sess,
|
|||
/* find output node */
|
||||
if ((str = spa_dict_lookup(dict, PW_KEY_LINK_OUTPUT_NODE)) != NULL &&
|
||||
(obj = find_object(impl, atoi(str))) != NULL &&
|
||||
obj->type == PW_TYPE_INTERFACE_Node) {
|
||||
strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) {
|
||||
outnode = (struct sm_node*)obj;
|
||||
}
|
||||
|
||||
/* find input node */
|
||||
if ((str = spa_dict_lookup(dict, PW_KEY_LINK_INPUT_NODE)) != NULL &&
|
||||
(obj = find_object(impl, atoi(str))) != NULL &&
|
||||
obj->type == PW_TYPE_INTERFACE_Node) {
|
||||
strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) {
|
||||
innode = (struct sm_node*)obj;
|
||||
}
|
||||
|
||||
/* find endpoints and streams */
|
||||
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_OUTPUT_ENDPOINT)) != NULL &&
|
||||
(obj = find_object(impl, atoi(str))) != NULL &&
|
||||
obj->type == PW_TYPE_INTERFACE_Endpoint) {
|
||||
strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
|
||||
outendpoint = (struct sm_endpoint*)obj;
|
||||
}
|
||||
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_OUTPUT_STREAM)) != NULL &&
|
||||
(obj = find_object(impl, atoi(str))) != NULL &&
|
||||
obj->type == PW_TYPE_INTERFACE_EndpointStream) {
|
||||
strcmp(obj->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
|
||||
outstream = (struct sm_endpoint_stream*)obj;
|
||||
}
|
||||
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_INPUT_ENDPOINT)) != NULL &&
|
||||
(obj = find_object(impl, atoi(str))) != NULL &&
|
||||
obj->type == PW_TYPE_INTERFACE_Endpoint) {
|
||||
strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
|
||||
inendpoint = (struct sm_endpoint*)obj;
|
||||
}
|
||||
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_INPUT_STREAM)) != NULL &&
|
||||
(obj = find_object(impl, atoi(str))) != NULL &&
|
||||
obj->type == PW_TYPE_INTERFACE_EndpointStream) {
|
||||
strcmp(obj->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
|
||||
instream = (struct sm_endpoint_stream*)obj;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct sm_object_events {
|
|||
|
||||
struct sm_object {
|
||||
uint32_t id;
|
||||
uint32_t type;
|
||||
const char *type;
|
||||
|
||||
struct spa_list link;
|
||||
struct sm_media_session *session;
|
||||
|
|
@ -226,14 +226,14 @@ struct sm_object *sm_media_session_find_object(struct sm_media_session *sess, ui
|
|||
int sm_media_session_schedule_rescan(struct sm_media_session *sess);
|
||||
|
||||
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
|
||||
uint32_t type, const struct spa_dict *props,
|
||||
const char *type, const struct spa_dict *props,
|
||||
void *object, size_t user_data_size);
|
||||
|
||||
struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
|
||||
const struct spa_dict *props, struct spa_device *device);
|
||||
|
||||
struct pw_proxy *sm_media_session_create_object(struct sm_media_session *sess,
|
||||
const char *factory_name, uint32_t type, uint32_t version,
|
||||
const char *factory_name, const char *type, uint32_t version,
|
||||
const struct spa_dict *props, size_t user_data_size);
|
||||
|
||||
struct sm_node *sm_media_session_create_node(struct sm_media_session *sess,
|
||||
|
|
|
|||
|
|
@ -219,19 +219,13 @@ static void session_create(void *data, struct sm_object *object)
|
|||
struct impl *impl = data;
|
||||
int res;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Endpoint:
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Endpoint) == 0)
|
||||
res = handle_endpoint(impl, object);
|
||||
break;
|
||||
|
||||
case PW_TYPE_INTERFACE_EndpointStream:
|
||||
else if (strcmp(object->type, PW_TYPE_INTERFACE_EndpointStream) == 0)
|
||||
res = handle_stream(impl, object);
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
pw_log_warn(NAME" %p: can't handle global %d", impl, object->id);
|
||||
}
|
||||
|
|
@ -244,23 +238,15 @@ static void session_remove(void *data, struct sm_object *object)
|
|||
struct impl *impl = data;
|
||||
pw_log_debug(NAME " %p: remove global '%d'", impl, object->id);
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Endpoint:
|
||||
{
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
|
||||
struct endpoint *ep;
|
||||
if ((ep = sm_object_get_data(object, SESSION_KEY)) != NULL)
|
||||
destroy_endpoint(impl, ep);
|
||||
break;
|
||||
}
|
||||
case PW_TYPE_INTERFACE_EndpointStream:
|
||||
{
|
||||
else if (strcmp(object->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
|
||||
struct stream *s;
|
||||
if ((s = sm_object_get_data(object, SESSION_KEY)) != NULL)
|
||||
destroy_stream(impl, s);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sm_media_session_schedule_rescan(impl->session);
|
||||
|
|
@ -444,11 +430,11 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep)
|
|||
pw_log_info(NAME " %p: target:%d", impl, path_id);
|
||||
|
||||
if ((obj = sm_media_session_find_object(impl->session, path_id)) != NULL) {
|
||||
switch (obj->type) {
|
||||
case PW_TYPE_INTERFACE_Endpoint:
|
||||
if (strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
|
||||
peer = sm_object_get_data(obj, SESSION_KEY);
|
||||
goto do_link;
|
||||
case PW_TYPE_INTERFACE_Node:
|
||||
}
|
||||
else if (strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) {
|
||||
node = (struct sm_node*)obj;
|
||||
goto do_link_node;
|
||||
}
|
||||
|
|
@ -469,7 +455,7 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep)
|
|||
}
|
||||
|
||||
obj = sm_media_session_find_object(impl->session, ep->client_id);
|
||||
if (obj && obj->type == PW_TYPE_INTERFACE_Client) {
|
||||
if (obj && strcmp(obj->type, PW_TYPE_INTERFACE_Client) == 0) {
|
||||
pw_client_error((struct pw_client*)obj->proxy,
|
||||
ep->id, -ENOENT, "no endpoint available");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
|||
goto exit;
|
||||
}
|
||||
obj = sm_media_session_find_object(impl->session, atoi(str));
|
||||
if (obj == NULL || obj->type != PW_TYPE_INTERFACE_Endpoint) {
|
||||
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) {
|
||||
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
|
||||
res = -EINVAL;
|
||||
goto exit;
|
||||
|
|
@ -557,15 +557,11 @@ static void session_create(void *data, struct sm_object *object)
|
|||
struct impl *impl = data;
|
||||
int res;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Node:
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0)
|
||||
res = handle_node(impl, object);
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
pw_log_warn(NAME" %p: can't handle global %d: %s", impl,
|
||||
object->id, spa_strerror(res));
|
||||
|
|
@ -576,16 +572,10 @@ static void session_remove(void *data, struct sm_object *object)
|
|||
{
|
||||
struct impl *impl = data;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Node:
|
||||
{
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) {
|
||||
struct node *node;
|
||||
if ((node = sm_object_get_data(object, SESSION_KEY)) != NULL)
|
||||
destroy_node(impl, node);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
|||
goto exit;
|
||||
}
|
||||
obj = sm_media_session_find_object(impl->session, atoi(str));
|
||||
if (obj == NULL || obj->type != PW_TYPE_INTERFACE_Endpoint) {
|
||||
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) {
|
||||
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
|
||||
res = -EINVAL;
|
||||
goto exit;
|
||||
|
|
@ -591,15 +591,11 @@ static void session_create(void *data, struct sm_object *object)
|
|||
struct impl *impl = data;
|
||||
int res;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Device:
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0)
|
||||
res = handle_device(impl, object);
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
pw_log_warn(NAME" %p: can't handle global %d: %s", impl,
|
||||
object->id, spa_strerror(res));
|
||||
|
|
@ -610,16 +606,10 @@ static void session_remove(void *data, struct sm_object *object)
|
|||
{
|
||||
struct impl *impl = data;
|
||||
|
||||
switch (object->type) {
|
||||
case PW_TYPE_INTERFACE_Device:
|
||||
{
|
||||
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) {
|
||||
struct device *device;
|
||||
if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL)
|
||||
destroy_device(impl, device);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <spa/node/node.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/names.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/param/props.h>
|
||||
#include <spa/debug/dict.h>
|
||||
#include <spa/pod/builder.h>
|
||||
|
|
@ -121,7 +122,7 @@ static struct node *v4l2_create_node(struct device *dev, uint32_t id,
|
|||
|
||||
pw_log_debug("new node %u", id);
|
||||
|
||||
if (info->type != SPA_TYPE_INTERFACE_Node) {
|
||||
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -337,7 +338,7 @@ static struct device *v4l2_create_device(struct impl *impl, uint32_t id,
|
|||
|
||||
pw_log_debug("new device %u", id);
|
||||
|
||||
if (info->type != SPA_TYPE_INTERFACE_Device) {
|
||||
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -352,7 +353,7 @@ static struct device *v4l2_create_device(struct impl *impl, uint32_t id,
|
|||
}
|
||||
|
||||
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
|
||||
pw_log_error("can't get %d interface: %d", info->type, res);
|
||||
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
|
||||
goto unload_handle;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue