update for keys

This commit is contained in:
Wim Taymans 2019-05-24 15:47:05 +02:00
parent 2057d7955c
commit 7d5e860d0c
3 changed files with 24 additions and 23 deletions

View file

@ -136,7 +136,7 @@ struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, cons
if ((g->mask & mask) == 0) if ((g->mask & mask) == 0)
continue; continue;
if (g->props != NULL && if (g->props != NULL &&
(str = pw_properties_get(g->props, "node.name")) != NULL && (str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL &&
strcmp(str, name) == 0) strcmp(str, name) == 0)
return g; return g;
if (g->id == id) if (g->id == id)
@ -203,7 +203,7 @@ static void device_event_info(void *object, const struct pw_device_info *info)
i->owner_module = g->parent_id; i->owner_module = g->parent_id;
if (info->change_mask & PW_DEVICE_CHANGE_MASK_PROPS) { if (info->change_mask & PW_DEVICE_CHANGE_MASK_PROPS) {
i->driver = info->props ? i->driver = info->props ?
spa_dict_lookup(info->props, "device.api") : NULL; spa_dict_lookup(info->props, PW_KEY_DEVICE_API) : NULL;
if (i->proplist) if (i->proplist)
pa_proplist_update_dict(i->proplist, info->props); pa_proplist_update_dict(i->proplist, info->props);
else else
@ -434,9 +434,9 @@ static void client_event_info(void *object, const struct pw_client_info *info)
else else
i->proplist = pa_proplist_new_dict(info->props); i->proplist = pa_proplist_new_dict(info->props);
i->name = info->props ? i->name = info->props ?
spa_dict_lookup(info->props, "application.name") : NULL; spa_dict_lookup(info->props, PW_KEY_APP_NAME) : NULL;
i->driver = info->props ? i->driver = info->props ?
spa_dict_lookup(info->props, PW_CLIENT_PROP_PROTOCOL) : NULL; spa_dict_lookup(info->props, PW_KEY_PROTOCOL) : NULL;
} }
g->pending_seq = pw_proxy_sync(g->proxy, 0); g->pending_seq = pw_proxy_sync(g->proxy, 0);
} }
@ -496,7 +496,7 @@ static int set_mask(pa_context *c, struct global *g)
case PW_TYPE_INTERFACE_Device: case PW_TYPE_INTERFACE_Device:
if (g->props == NULL) if (g->props == NULL)
return 0; return 0;
if ((str = pw_properties_get(g->props, "media.class")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_MEDIA_CLASS)) == NULL)
return 0; return 0;
if (strcmp(str, "Audio/Device") != 0) if (strcmp(str, "Audio/Device") != 0)
return 0; return 0;
@ -514,7 +514,7 @@ static int set_mask(pa_context *c, struct global *g)
case PW_TYPE_INTERFACE_Node: case PW_TYPE_INTERFACE_Node:
if (g->props == NULL) if (g->props == NULL)
return 0; return 0;
if ((str = pw_properties_get(g->props, "media.class")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_MEDIA_CLASS)) == NULL)
return 0; return 0;
if (strcmp(str, "Audio/Sink") == 0) { if (strcmp(str, "Audio/Sink") == 0) {
@ -524,7 +524,7 @@ static int set_mask(pa_context *c, struct global *g)
g->node_info.monitor = SPA_ID_INVALID; g->node_info.monitor = SPA_ID_INVALID;
} }
else if (strcmp(str, "Audio/DSP/Playback") == 0) { else if (strcmp(str, "Audio/DSP/Playback") == 0) {
if ((str = pw_properties_get(g->props, "node.session")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_NODE_SESSION)) == NULL)
return 0; return 0;
pw_log_debug("found monitor %d", g->id); pw_log_debug("found monitor %d", g->id);
g->mask = PA_SUBSCRIPTION_MASK_DSP_SINK | PA_SUBSCRIPTION_MASK_SOURCE; g->mask = PA_SUBSCRIPTION_MASK_DSP_SINK | PA_SUBSCRIPTION_MASK_SOURCE;
@ -539,7 +539,7 @@ static int set_mask(pa_context *c, struct global *g)
g->event = PA_SUBSCRIPTION_EVENT_SOURCE; g->event = PA_SUBSCRIPTION_EVENT_SOURCE;
} }
else if (strcmp(str, "Audio/DSP/Capture") == 0) { else if (strcmp(str, "Audio/DSP/Capture") == 0) {
if ((str = pw_properties_get(g->props, "node.session")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_NODE_SESSION)) == NULL)
return 0; return 0;
g->mask = PA_SUBSCRIPTION_MASK_DSP_SOURCE; g->mask = PA_SUBSCRIPTION_MASK_DSP_SOURCE;
g->dsp_info.session = pw_properties_parse_int(str); g->dsp_info.session = pw_properties_parse_int(str);
@ -584,10 +584,10 @@ static int set_mask(pa_context *c, struct global *g)
break; break;
case PW_TYPE_INTERFACE_Link: case PW_TYPE_INTERFACE_Link:
if ((str = pw_properties_get(g->props, "link.output")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_LINK_OUTPUT_PORT)) == NULL)
return 0; return 0;
g->link_info.src = pa_context_find_global(c, pw_properties_parse_int(str)); g->link_info.src = pa_context_find_global(c, pw_properties_parse_int(str));
if ((str = pw_properties_get(g->props, "link.input")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_LINK_OUTPUT_PORT)) == NULL)
return 0; return 0;
g->link_info.dst = pa_context_find_global(c, pw_properties_parse_int(str)); g->link_info.dst = pa_context_find_global(c, pw_properties_parse_int(str));
@ -801,7 +801,7 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *
props = pw_properties_new(NULL, NULL); props = pw_properties_new(NULL, NULL);
if (name) if (name)
pw_properties_set(props, PA_PROP_APPLICATION_NAME, name); pw_properties_set(props, PA_PROP_APPLICATION_NAME, name);
pw_properties_set(props, "client.api", "pulseaudio"); pw_properties_set(props, PW_KEY_CLIENT_API, "pulseaudio");
if (p) if (p)
pw_properties_update(props, &p->props->dict); pw_properties_update(props, &p->props->dict);

View file

@ -1433,8 +1433,8 @@ static void sink_input_callback(struct sink_input_data *d)
s = find_stream(d->context, g->id); s = find_stream(d->context, g->id);
if (info->props) { if (info->props) {
if ((name = spa_dict_lookup(info->props, "media.name")) == NULL && if ((name = spa_dict_lookup(info->props, PW_KEY_MEDIA_NAME)) == NULL &&
(name = spa_dict_lookup(info->props, "application.name")) == NULL) (name = spa_dict_lookup(info->props, PW_KEY_APP_NAME)) == NULL)
name = info->name; name = info->name;
} }
else else
@ -1726,8 +1726,8 @@ static void source_output_callback(struct source_output_data *d)
s = find_stream(d->context, g->id); s = find_stream(d->context, g->id);
if (info->props) { if (info->props) {
if ((name = spa_dict_lookup(info->props, "media.name")) == NULL && if ((name = spa_dict_lookup(info->props, PW_KEY_MEDIA_NAME)) == NULL &&
(name = spa_dict_lookup(info->props, "application.name")) == NULL) (name = spa_dict_lookup(info->props, PW_KEY_APP_NAME)) == NULL)
name = info->name; name = info->name;
} }
else else

View file

@ -28,6 +28,7 @@
#include <pulse/xmalloc.h> #include <pulse/xmalloc.h>
#include <pipewire/stream.h> #include <pipewire/stream.h>
#include <pipewire/keys.h>
#include "core-format.h" #include "core-format.h"
#include "internal.h" #include "internal.h"
@ -197,7 +198,7 @@ static void configure_device(pa_stream *s)
} }
else { else {
s->device_index = g->id; s->device_index = g->id;
if ((str = pw_properties_get(g->props, "node.name")) == NULL) if ((str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) == NULL)
s->device_name = strdup("unknown"); s->device_name = strdup("unknown");
else else
s->device_name = strdup(str); s->device_name = strdup(str);
@ -526,7 +527,7 @@ static pa_stream* stream_new(pa_context *c, const char *name,
else else
name = pa_proplist_gets(s->proplist, PA_PROP_MEDIA_NAME); name = pa_proplist_gets(s->proplist, PA_PROP_MEDIA_NAME);
props = pw_properties_new("client.api", "pulseaudio", props = pw_properties_new(PW_KEY_CLIENT_API, "pulseaudio",
NULL); NULL);
pw_properties_update(props, &s->proplist->props->dict); pw_properties_update(props, &s->proplist->props->dict);
@ -941,13 +942,13 @@ static int create_stream(pa_stream_direction_t direction,
str = "Music"; str = "Music";
sprintf(latency, "%u/%u", s->buffer_attr.minreq / stride, sample_rate); sprintf(latency, "%u/%u", s->buffer_attr.minreq / stride, sample_rate);
items[0] = SPA_DICT_ITEM_INIT("node.latency", latency); items[0] = SPA_DICT_ITEM_INIT(PW_KEY_NODE_LATENCY, latency);
items[1] = SPA_DICT_ITEM_INIT(PW_NODE_PROP_MEDIA, "Audio"); items[1] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_TYPE, "Audio");
items[2] = SPA_DICT_ITEM_INIT(PW_NODE_PROP_CATEGORY, items[2] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_CATEGORY,
direction == PA_STREAM_PLAYBACK ? direction == PA_STREAM_PLAYBACK ?
"Playback" : "Capture"); "Playback" : "Capture");
items[3] = SPA_DICT_ITEM_INIT(PW_NODE_PROP_ROLE, str); items[3] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_ROLE, str);
items[4] = SPA_DICT_ITEM_INIT("pipewire.monitor", monitor ? "1" : "0"); items[4] = SPA_DICT_ITEM_INIT(PW_KEY_STREAM_MONITOR, monitor ? "1" : "0");
pw_stream_update_properties(s->stream, &SPA_DICT_INIT(items, 5)); pw_stream_update_properties(s->stream, &SPA_DICT_INIT(items, 5));
@ -1587,7 +1588,7 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
items[0] = SPA_DICT_ITEM_INIT("media.name", name); items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_NAME, name);
dict = SPA_DICT_INIT(items, 1); dict = SPA_DICT_INIT(items, 1);
pw_stream_update_properties(s->stream, &dict); pw_stream_update_properties(s->stream, &dict);