mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
zeroconf: use pa_get_{user|host}_name_malloc() where applicable
This commit is contained in:
parent
3522b7d150
commit
5a2898db8a
1 changed files with 14 additions and 8 deletions
|
|
@ -339,7 +339,7 @@ finish:
|
||||||
|
|
||||||
static struct service *get_service(struct userdata *u, pa_object *device) {
|
static struct service *get_service(struct userdata *u, pa_object *device) {
|
||||||
struct service *s;
|
struct service *s;
|
||||||
char hn[64], un[64];
|
char *hn, *un;
|
||||||
const char *n;
|
const char *n;
|
||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
|
|
@ -361,11 +361,13 @@ static struct service *get_service(struct userdata *u, pa_object *device) {
|
||||||
n = PA_SOURCE(device)->name;
|
n = PA_SOURCE(device)->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->service_name = pa_truncate_utf8(pa_sprintf_malloc("%s@%s: %s",
|
hn = pa_get_host_name_malloc();
|
||||||
pa_get_user_name(un, sizeof(un)),
|
un = pa_get_user_name_malloc();
|
||||||
pa_get_host_name(hn, sizeof(hn)),
|
|
||||||
n),
|
s->service_name = pa_truncate_utf8(pa_sprintf_malloc("%s@%s: %s", un, hn, n), AVAHI_LABEL_MAX-1);
|
||||||
AVAHI_LABEL_MAX-1);
|
|
||||||
|
pa_xfree(un);
|
||||||
|
pa_xfree(hn);
|
||||||
|
|
||||||
pa_hashmap_put(u->services, s->device, s);
|
pa_hashmap_put(u->services, s->device, s);
|
||||||
|
|
||||||
|
|
@ -605,7 +607,7 @@ int pa__init(pa_module*m) {
|
||||||
|
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
pa_modargs *ma = NULL;
|
pa_modargs *ma = NULL;
|
||||||
char hn[256], un[256];
|
char *hn, *un;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||||
|
|
@ -631,7 +633,11 @@ int pa__init(pa_module*m) {
|
||||||
|
|
||||||
u->main_entry_group = NULL;
|
u->main_entry_group = NULL;
|
||||||
|
|
||||||
u->service_name = pa_truncate_utf8(pa_sprintf_malloc("%s@%s", pa_get_user_name(un, sizeof(un)), pa_get_host_name(hn, sizeof(hn))), AVAHI_LABEL_MAX);
|
un = pa_get_user_name_malloc();
|
||||||
|
hn = pa_get_host_name_malloc();
|
||||||
|
u->service_name = pa_truncate_utf8(pa_sprintf_malloc("%s@%s", un, hn), AVAHI_LABEL_MAX-1);
|
||||||
|
pa_xfree(un);
|
||||||
|
pa_xfree(hn);
|
||||||
|
|
||||||
if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
|
if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
|
||||||
pa_log("avahi_client_new() failed: %s", avahi_strerror(error));
|
pa_log("avahi_client_new() failed: %s", avahi_strerror(error));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue