Merge pull request #876 from whatdoineed2do/multi-alsa-nickname-fix

[alsa] multi alsa cfg section SEGV with no nickname
This commit is contained in:
ejurgensen 2020-01-06 17:09:56 +01:00 committed by GitHub
commit 04a43919a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1188,13 +1188,13 @@ alsa_device_add(cfg_t* cfg_audio, int id)
{
struct output_device *device;
struct alsa_extra *ae;
const char *nickname;
int ret;
CHECK_NULL(L_LAUDIO, device = calloc(1, sizeof(struct output_device)));
CHECK_NULL(L_LAUDIO, ae = calloc(1, sizeof(struct alsa_extra)));
device->id = id;
device->name = strdup(cfg_getstr(cfg_audio, "nickname"));
device->type = OUTPUT_TYPE_ALSA;
device->type_name = outputs_name(device->type);
device->extra_device_info = ae;
@ -1205,6 +1205,9 @@ alsa_device_add(cfg_t* cfg_audio, int id)
if (!ae->card_name)
ae->card_name = cfg_getstr(cfg_audio, "card");
nickname = cfg_getstr(cfg_audio, "nickname");
device->name = strdup(nickname ? nickname : ae->card_name);
ae->mixer_name = cfg_getstr(cfg_audio, "mixer");
ae->mixer_device_name = cfg_getstr(cfg_audio, "mixer_device");
if (!ae->mixer_device_name || strlen(ae->mixer_device_name) == 0)