mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
adapter: improve port names
This commit is contained in:
parent
3d302ffd4d
commit
24d4eb585f
1 changed files with 26 additions and 12 deletions
|
|
@ -179,31 +179,43 @@ static void node_port_init(void *data, struct pw_port *port)
|
||||||
const struct pw_properties *old;
|
const struct pw_properties *old;
|
||||||
enum pw_direction direction;
|
enum pw_direction direction;
|
||||||
struct pw_properties *new;
|
struct pw_properties *new;
|
||||||
const char *str;
|
const char *str, *node_name, *media_class;
|
||||||
void *iface;
|
void *iface;
|
||||||
const struct spa_support *support;
|
const struct spa_support *support;
|
||||||
uint32_t n_support;
|
uint32_t n_support;
|
||||||
char position[8], *prefix;
|
char position[8], *prefix;
|
||||||
bool monitor;
|
bool is_monitor, is_device;
|
||||||
|
|
||||||
direction = pw_port_get_direction(port);
|
direction = pw_port_get_direction(port);
|
||||||
|
|
||||||
old = pw_port_get_properties(port);
|
old = pw_port_get_properties(port);
|
||||||
|
|
||||||
monitor = (str = pw_properties_get(old, PW_KEY_PORT_MONITOR)) != NULL &&
|
is_monitor = (str = pw_properties_get(old, PW_KEY_PORT_MONITOR)) != NULL &&
|
||||||
pw_properties_parse_bool(str);
|
pw_properties_parse_bool(str);
|
||||||
|
|
||||||
if (!monitor && direction != n->direction)
|
if (!is_monitor && direction != n->direction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new = pw_properties_new(PW_KEY_FORMAT_DSP, "32 bit float mono audio", NULL);
|
node_name = pw_properties_get(n->props, PW_KEY_NODE_NAME);
|
||||||
|
media_class = pw_properties_get(n->props, PW_KEY_MEDIA_CLASS);
|
||||||
|
|
||||||
if (monitor)
|
if (media_class != NULL &&
|
||||||
prefix = "monitor";
|
(strstr(media_class, "Sink") != NULL ||
|
||||||
else if (direction == PW_DIRECTION_INPUT)
|
strstr(media_class, "Source") != NULL))
|
||||||
prefix = "playback";
|
is_device = true;
|
||||||
else
|
else
|
||||||
prefix = "capture";
|
is_device = false;
|
||||||
|
|
||||||
|
new = pw_properties_new(NULL, NULL);
|
||||||
|
|
||||||
|
if (is_monitor)
|
||||||
|
prefix = "monitor";
|
||||||
|
else if (is_device)
|
||||||
|
prefix = direction == PW_DIRECTION_INPUT ?
|
||||||
|
"playback" : "capture";
|
||||||
|
else
|
||||||
|
prefix = direction == PW_DIRECTION_INPUT ?
|
||||||
|
"input" : "output";
|
||||||
|
|
||||||
if ((str = pw_properties_get(old, PW_KEY_AUDIO_CHANNEL)) == NULL ||
|
if ((str = pw_properties_get(old, PW_KEY_AUDIO_CHANNEL)) == NULL ||
|
||||||
strcmp(str, "UNK") == 0) {
|
strcmp(str, "UNK") == 0) {
|
||||||
|
|
@ -214,9 +226,11 @@ static void node_port_init(void *data, struct pw_port *port)
|
||||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
||||||
|
|
||||||
if (direction == n->direction) {
|
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",
|
pw_properties_setf(new, PW_KEY_PORT_ALIAS1, "%s_pcm:%s:%s%s",
|
||||||
pw_properties_get(n->props, PW_KEY_DEVICE_API),
|
api ? api : "adapter",
|
||||||
pw_properties_get(n->props, PW_KEY_NODE_NAME),
|
node_name ? node_name : "node",
|
||||||
direction == PW_DIRECTION_INPUT ? "in" : "out",
|
direction == PW_DIRECTION_INPUT ? "in" : "out",
|
||||||
str);
|
str);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue