mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
module-raop: Avoid props creation for duplicates
This commit is contained in:
parent
da86c2030c
commit
389cbe7aef
1 changed files with 18 additions and 29 deletions
|
|
@ -126,9 +126,6 @@ struct impl {
|
||||||
|
|
||||||
struct tunnel_info {
|
struct tunnel_info {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *host_name;
|
|
||||||
const char *ip;
|
|
||||||
const char *port;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TUNNEL_INFO(...) ((struct tunnel_info){ __VA_ARGS__ })
|
#define TUNNEL_INFO(...) ((struct tunnel_info){ __VA_ARGS__ })
|
||||||
|
|
@ -151,9 +148,6 @@ static struct tunnel *make_tunnel(struct impl *impl, const struct tunnel_info *i
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
t->info.name = strdup(info->name);
|
t->info.name = strdup(info->name);
|
||||||
t->info.host_name = strdup(info->host_name);
|
|
||||||
t->info.ip = strdup(info->ip);
|
|
||||||
t->info.port = strdup(info->port);
|
|
||||||
spa_list_append(&impl->tunnel_list, &t->link);
|
spa_list_append(&impl->tunnel_list, &t->link);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
@ -175,9 +169,6 @@ static void free_tunnel(struct tunnel *t)
|
||||||
if (t->module)
|
if (t->module)
|
||||||
pw_impl_module_destroy(t->module);
|
pw_impl_module_destroy(t->module);
|
||||||
free((char *) t->info.name);
|
free((char *) t->info.name);
|
||||||
free((char *) t->info.host_name);
|
|
||||||
free((char *) t->info.ip);
|
|
||||||
free((char *) t->info.port);
|
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,10 +358,11 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
|
||||||
struct impl *impl = userdata;
|
struct impl *impl = userdata;
|
||||||
struct tunnel_info tinfo;
|
struct tunnel_info tinfo;
|
||||||
struct tunnel *t;
|
struct tunnel *t;
|
||||||
const char *str, *port_str;
|
const char *str;
|
||||||
AvahiStringList *l;
|
AvahiStringList *l;
|
||||||
struct pw_properties *props = NULL;
|
struct pw_properties *props = NULL;
|
||||||
char at[AVAHI_ADDRESS_STR_MAX];
|
char at[AVAHI_ADDRESS_STR_MAX];
|
||||||
|
int ipv;
|
||||||
|
|
||||||
if (event != AVAHI_RESOLVER_FOUND) {
|
if (event != AVAHI_RESOLVER_FOUND) {
|
||||||
pw_log_error("Resolving of '%s' failed: %s", name,
|
pw_log_error("Resolving of '%s' failed: %s", name,
|
||||||
|
|
@ -378,7 +370,19 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
avahi_address_snprint(at, sizeof(at), a);
|
tinfo = TUNNEL_INFO(.name = name);
|
||||||
|
|
||||||
|
t = find_tunnel(impl, &tinfo);
|
||||||
|
if (t == NULL)
|
||||||
|
t = make_tunnel(impl, &tinfo);
|
||||||
|
if (t == NULL) {
|
||||||
|
pw_log_error("Can't make tunnel: %m");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (t->module != NULL) {
|
||||||
|
pw_log_info("found duplicate mdns entry - skipping tunnel creation");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
props = pw_properties_new(NULL, NULL);
|
props = pw_properties_new(NULL, NULL);
|
||||||
if (props == NULL) {
|
if (props == NULL) {
|
||||||
|
|
@ -386,7 +390,10 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avahi_address_snprint(at, sizeof(at), a);
|
||||||
|
ipv = protocol == AVAHI_PROTO_INET ? 4 : 6;
|
||||||
pw_properties_setf(props, "raop.ip", "%s", at);
|
pw_properties_setf(props, "raop.ip", "%s", at);
|
||||||
|
pw_properties_setf(props, "raop.ip.version", "%d", ipv);
|
||||||
pw_properties_setf(props, "raop.port", "%u", port);
|
pw_properties_setf(props, "raop.port", "%u", port);
|
||||||
pw_properties_setf(props, "raop.name", "%s", name);
|
pw_properties_setf(props, "raop.name", "%s", name);
|
||||||
pw_properties_setf(props, "raop.hostname", "%s", host_name);
|
pw_properties_setf(props, "raop.hostname", "%s", host_name);
|
||||||
|
|
@ -403,24 +410,6 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
|
||||||
avahi_free(value);
|
avahi_free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
port_str = pw_properties_get(props, "raop.port");
|
|
||||||
|
|
||||||
tinfo = TUNNEL_INFO(.name = name,
|
|
||||||
.host_name = host_name,
|
|
||||||
.ip = at,
|
|
||||||
.port = port_str);
|
|
||||||
t = find_tunnel(impl, &tinfo);
|
|
||||||
if (t == NULL)
|
|
||||||
t = make_tunnel(impl, &tinfo);
|
|
||||||
if (t == NULL) {
|
|
||||||
pw_log_error("Can't make tunnel: %m");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (t->module != NULL) {
|
|
||||||
pw_log_info("found duplicate mdns entry - skipping tunnel creation");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((str = pw_properties_get(impl->properties, "stream.rules")) == NULL)
|
if ((str = pw_properties_get(impl->properties, "stream.rules")) == NULL)
|
||||||
str = DEFAULT_CREATE_RULES;
|
str = DEFAULT_CREATE_RULES;
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue