mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-23 00:35:36 +00:00
alsa: refactor for readability
This commit is contained in:
parent
376ba4a4e6
commit
c2836e494b
11
src/alsa.c
11
src/alsa.c
|
@ -516,6 +516,7 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// One or both of descr and descr1 can be NULL.
|
||||||
char *descr = snd_device_name_get_hint(*hint_ptr, "DESC");
|
char *descr = snd_device_name_get_hint(*hint_ptr, "DESC");
|
||||||
char *descr1 = str_partition_on_char(descr, '\n');
|
char *descr1 = str_partition_on_char(descr, '\n');
|
||||||
|
|
||||||
|
@ -574,9 +575,13 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
device->soundio = soundio;
|
device->soundio = soundio;
|
||||||
device->is_raw = false;
|
device->is_raw = false;
|
||||||
device->id = strdup(name);
|
device->id = strdup(name);
|
||||||
device->name = descr1 ?
|
if (descr1) {
|
||||||
soundio_alloc_sprintf(NULL, "%s: %s", descr, descr1) : descr ?
|
device->name = soundio_alloc_sprintf(NULL, "%s: %s", descr, descr1);
|
||||||
strdup(descr) : strdup(name);
|
} else if (descr) {
|
||||||
|
device->name = strdup(descr);
|
||||||
|
} else {
|
||||||
|
device->name = strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!device->id || !device->name) {
|
if (!device->id || !device->name) {
|
||||||
soundio_device_unref(device);
|
soundio_device_unref(device);
|
||||||
|
|
Loading…
Reference in a new issue