mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05: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
|
|
@ -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