mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
alsa: Handle pa_device_port_new() failures
pa_device_port_new() can't currently fail, but it soon can.
This commit is contained in:
parent
66f5a68732
commit
c2c00ce6c2
2 changed files with 33 additions and 5 deletions
|
|
@ -4500,7 +4500,12 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
|
|||
|
||||
p = pa_device_port_new(core, &port_data, sizeof(pa_alsa_port_data));
|
||||
pa_device_port_new_data_done(&port_data);
|
||||
pa_assert(p);
|
||||
|
||||
if (!p) {
|
||||
pa_log("Failed to create port %s.", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pa_hashmap_put(ports, p->name, p);
|
||||
pa_proplist_update(p->proplist, PA_UPDATE_REPLACE, path->proplist);
|
||||
|
||||
|
|
@ -4519,6 +4524,9 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
|
|||
}
|
||||
|
||||
return p;
|
||||
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void pa_alsa_path_set_add_ports(
|
||||
|
|
@ -4542,6 +4550,10 @@ void pa_alsa_path_set_add_ports(
|
|||
* single entry */
|
||||
pa_device_port *port = device_port_alsa_init(ports, path->name,
|
||||
path->description, path, path->settings, cp, extra, core);
|
||||
|
||||
if (!port)
|
||||
continue;
|
||||
|
||||
port->priority = path->priority * 100;
|
||||
|
||||
} else {
|
||||
|
|
@ -4558,10 +4570,13 @@ void pa_alsa_path_set_add_ports(
|
|||
d = pa_xstrdup(path->description);
|
||||
|
||||
port = device_port_alsa_init(ports, n, d, path, s, cp, extra, core);
|
||||
port->priority = path->priority * 100 + s->priority;
|
||||
|
||||
pa_xfree(n);
|
||||
pa_xfree(d);
|
||||
|
||||
if (!port)
|
||||
continue;
|
||||
|
||||
port->priority = path->priority * 100 + s->priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -678,7 +678,8 @@ static void ucm_add_port_combination(
|
|||
int i;
|
||||
unsigned priority;
|
||||
double prio2;
|
||||
char *name, *desc;
|
||||
char *name = NULL;
|
||||
char *desc = NULL;
|
||||
const char *dev_name;
|
||||
const char *direction;
|
||||
pa_alsa_ucm_device *dev;
|
||||
|
|
@ -731,7 +732,11 @@ static void ucm_add_port_combination(
|
|||
|
||||
port = pa_device_port_new(core, &port_data, 0);
|
||||
pa_device_port_new_data_done(&port_data);
|
||||
pa_assert(port);
|
||||
|
||||
if (!port) {
|
||||
pa_log("Failed to create port %s.", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pa_hashmap_put(ports, port->name, port);
|
||||
pa_log_debug("Add port %s: %s", port->name, port->description);
|
||||
|
|
@ -741,7 +746,9 @@ static void ucm_add_port_combination(
|
|||
port->priority = priority;
|
||||
|
||||
pa_xfree(name);
|
||||
name = NULL;
|
||||
pa_xfree(desc);
|
||||
desc = NULL;
|
||||
|
||||
direction = is_sink ? "output" : "input";
|
||||
pa_log_debug("Port %s direction %s, priority %d", port->name, direction, priority);
|
||||
|
|
@ -755,6 +762,12 @@ static void ucm_add_port_combination(
|
|||
pa_hashmap_put(hash, port->name, port);
|
||||
pa_device_port_ref(port);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
pa_xfree(name);
|
||||
pa_xfree(desc);
|
||||
}
|
||||
|
||||
static int ucm_port_contains(const char *port_name, const char *dev_name, bool is_sink) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue