mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
improve properties on node and port
Rename some alsa filenames.
This commit is contained in:
parent
77e07e1948
commit
db341a6450
17 changed files with 249 additions and 139 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include <spa/node/node.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/names.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/param/props.h>
|
||||
#include <spa/debug/dict.h>
|
||||
|
|
@ -96,7 +97,7 @@ static struct alsa_node *alsa_create_node(struct alsa_object *obj, uint32_t id,
|
|||
struct monitor *monitor = obj->monitor;
|
||||
struct impl *impl = monitor->impl;
|
||||
int res;
|
||||
const char *str;
|
||||
const char *dev, *subdev;
|
||||
|
||||
pw_log_debug("new node %u", id);
|
||||
|
||||
|
|
@ -115,26 +116,47 @@ static struct alsa_node *alsa_create_node(struct alsa_object *obj, uint32_t id,
|
|||
if (obj->device_id != 0)
|
||||
pw_properties_setf(node->props, PW_KEY_DEVICE_ID, "%d", obj->device_id);
|
||||
|
||||
if ((str = pw_properties_get(obj->props, SPA_KEY_DEVICE_NICK)) != NULL)
|
||||
pw_properties_set(node->props, PW_KEY_NODE_NICK, str);
|
||||
|
||||
str = pw_properties_get(obj->props, SPA_KEY_DEVICE_NAME);
|
||||
if (str == NULL)
|
||||
str = pw_properties_get(obj->props, SPA_KEY_DEVICE_NICK);
|
||||
if (str == NULL)
|
||||
str = pw_properties_get(obj->props, SPA_KEY_DEVICE_ALIAS);
|
||||
if (str == NULL)
|
||||
str = "alsa-device";
|
||||
|
||||
pw_properties_setf(node->props, PW_KEY_NODE_NAME, "%s.%s", info->factory_name, str);
|
||||
|
||||
str = pw_properties_get(obj->props, SPA_KEY_DEVICE_DESCRIPTION);
|
||||
if (str == NULL)
|
||||
str = "alsa-device";
|
||||
pw_properties_set(node->props, PW_KEY_NODE_DESCRIPTION, str);
|
||||
|
||||
pw_properties_set(node->props, "factory.name", info->factory_name);
|
||||
|
||||
if ((dev = pw_properties_get(node->props, SPA_KEY_API_ALSA_PCM_DEVICE)) == NULL)
|
||||
dev = "0";
|
||||
if ((subdev = pw_properties_get(node->props, SPA_KEY_API_ALSA_PCM_SUBDEVICE)) == NULL)
|
||||
subdev = "0";
|
||||
|
||||
if (pw_properties_get(node->props, SPA_KEY_NODE_NAME) == NULL) {
|
||||
const char *devname, *stream;
|
||||
if ((devname = pw_properties_get(obj->props, SPA_KEY_DEVICE_NAME)) == NULL)
|
||||
devname = "unknown";
|
||||
if ((stream = pw_properties_get(node->props, SPA_KEY_API_ALSA_PCM_STREAM)) == NULL)
|
||||
stream = "unknown";
|
||||
|
||||
pw_properties_setf(node->props, SPA_KEY_NODE_NAME, "%s.%s.%s.%s",
|
||||
devname, stream, dev, subdev);
|
||||
}
|
||||
if (pw_properties_get(node->props, PW_KEY_NODE_DESCRIPTION) == NULL) {
|
||||
const char *desc, *name = NULL;
|
||||
|
||||
if ((desc = pw_properties_get(obj->props, SPA_KEY_DEVICE_DESCRIPTION)) == NULL)
|
||||
desc = "unknown";
|
||||
|
||||
name = pw_properties_get(node->props, SPA_KEY_API_ALSA_PCM_NAME);
|
||||
if (name == NULL)
|
||||
name = pw_properties_get(node->props, SPA_KEY_API_ALSA_PCM_ID);
|
||||
if (name == NULL)
|
||||
name = dev;
|
||||
|
||||
if (strcmp(subdev, "0")) {
|
||||
pw_properties_setf(node->props, PW_KEY_NODE_DESCRIPTION, "%s (%s %s)",
|
||||
desc, name, subdev);
|
||||
} else if (strcmp(dev, "0")) {
|
||||
pw_properties_setf(node->props, PW_KEY_NODE_DESCRIPTION, "%s (%s)",
|
||||
desc, name);
|
||||
} else {
|
||||
pw_properties_setf(node->props, PW_KEY_NODE_DESCRIPTION, "%s",
|
||||
desc);
|
||||
}
|
||||
}
|
||||
|
||||
node->monitor = monitor;
|
||||
node->object = obj;
|
||||
node->id = id;
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ static void node_port_init(void *data, struct pw_port *port)
|
|||
const struct pw_properties *old;
|
||||
enum pw_direction direction;
|
||||
struct pw_properties *new;
|
||||
const char *str, *node_name, *media_class;
|
||||
const char *str, *path, *node_name, *media_class;
|
||||
void *iface;
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
|
|
@ -204,7 +204,7 @@ static void node_port_init(void *data, struct pw_port *port)
|
|||
if (!is_monitor && direction != n->direction)
|
||||
return;
|
||||
|
||||
node_name = pw_properties_get(n->props, PW_KEY_NODE_NAME);
|
||||
path = pw_properties_get(n->props, PW_KEY_OBJECT_PATH);
|
||||
media_class = pw_properties_get(n->props, PW_KEY_MEDIA_CLASS);
|
||||
|
||||
if (media_class != NULL &&
|
||||
|
|
@ -230,24 +230,25 @@ static void node_port_init(void *data, struct pw_port *port)
|
|||
snprintf(position, 7, "%d", port->port_id);
|
||||
str = position;
|
||||
}
|
||||
|
||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
||||
|
||||
if (direction == n->direction) {
|
||||
const char *api = pw_properties_get(n->props, PW_KEY_DEVICE_API);
|
||||
|
||||
pw_properties_setf(new, PW_KEY_PORT_ALIAS1, "%s_pcm:%s:%s%s",
|
||||
api ? api : "adapter",
|
||||
node_name ? node_name : "node",
|
||||
direction == PW_DIRECTION_INPUT ? "in" : "out",
|
||||
str);
|
||||
|
||||
if (is_device) {
|
||||
pw_properties_set(new, PW_KEY_PORT_PHYSICAL, "1");
|
||||
pw_properties_set(new, PW_KEY_PORT_TERMINAL, "1");
|
||||
}
|
||||
}
|
||||
|
||||
if ((node_name = pw_properties_get(n->props, PW_KEY_NODE_DESCRIPTION)) == NULL &&
|
||||
(node_name = pw_properties_get(n->props, PW_KEY_NODE_NICK)) == NULL &&
|
||||
(node_name = pw_properties_get(n->props, PW_KEY_NODE_NAME)) == NULL) {
|
||||
node_name = "node";
|
||||
}
|
||||
pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d",
|
||||
path ? path : node_name, prefix, port->port_id);
|
||||
|
||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%d", prefix, port->port_id);
|
||||
pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s",
|
||||
node_name, prefix, str);
|
||||
|
||||
pw_port_update_properties(port, &new->dict);
|
||||
pw_properties_free(new);
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ extern "C" {
|
|||
#define PW_KEY_LIBRARY_NAME_LOOP "library.name.loop" /**< name of the loop library to use */
|
||||
#define PW_KEY_LIBRARY_NAME_DBUS "library.name.dbus" /**< name of the dbus library to use */
|
||||
|
||||
#define PW_KEY_OBJECT_PATH "object.path" /**< unique path to construct the object */
|
||||
#define PW_KEY_OBJECT_ID "object.id" /**< a global object id */
|
||||
|
||||
#define PW_KEY_CORE_ID "core.id" /**< the core id */
|
||||
|
|
@ -133,8 +134,7 @@ extern "C" {
|
|||
#define PW_KEY_PORT_NAME "port.name" /**< port name */
|
||||
#define PW_KEY_PORT_DIRECTION "port.direction" /**< the port direction, one of "in" or "out"
|
||||
* or "control" and "notify" for control ports */
|
||||
#define PW_KEY_PORT_ALIAS1 "port.alias1" /**< port alias1 */
|
||||
#define PW_KEY_PORT_ALIAS2 "port.alias2" /**< port alias2 */
|
||||
#define PW_KEY_PORT_ALIAS "port.alias" /**< port alias */
|
||||
#define PW_KEY_PORT_PHYSICAL "port.physical" /**< if this is a physical port */
|
||||
#define PW_KEY_PORT_TERMINAL "port.terminal" /**< if this port consumes the data */
|
||||
#define PW_KEY_PORT_CONTROL "port.control" /**< if this port is a control port */
|
||||
|
|
|
|||
|
|
@ -549,6 +549,7 @@ int pw_node_register(struct pw_node *this,
|
|||
struct pw_core *core = this->core;
|
||||
struct pw_port *port;
|
||||
const char *keys[] = {
|
||||
PW_KEY_OBJECT_PATH,
|
||||
PW_KEY_CLIENT_ID,
|
||||
PW_KEY_DEVICE_ID,
|
||||
PW_KEY_NODE_DESCRIPTION,
|
||||
|
|
|
|||
|
|
@ -679,14 +679,14 @@ int pw_port_register(struct pw_port *port,
|
|||
{
|
||||
struct pw_node *node = port->node;
|
||||
const char *keys[] = {
|
||||
PW_KEY_OBJECT_PATH,
|
||||
PW_KEY_FORMAT_DSP,
|
||||
PW_KEY_PORT_NAME,
|
||||
PW_KEY_PORT_DIRECTION,
|
||||
PW_KEY_PORT_PHYSICAL,
|
||||
PW_KEY_PORT_TERMINAL,
|
||||
PW_KEY_PORT_CONTROL,
|
||||
PW_KEY_PORT_ALIAS1,
|
||||
PW_KEY_PORT_ALIAS2,
|
||||
PW_KEY_PORT_ALIAS,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue