Skip to content

Commit 328dadc

Browse files
padenotachronop
authored andcommitted
Handle devices without name in cubeb_audiounit.cpp
1 parent 87d2fc2 commit 328dadc

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/cubeb_audiounit.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,15 @@ audiounit_create_device_from_hwdev(cubeb_device_info * ret, AudioObjectID devid,
31573157
}
31583158
}
31593159

3160-
ret->friendly_name = audiounit_strref_to_cstr_utf8(str);
3160+
if (str) {
3161+
ret->friendly_name = audiounit_strref_to_cstr_utf8(str);
3162+
} else {
3163+
// Couldn't get a friendly_name, nor a datasource name, return a valid
3164+
// string of length 0.
3165+
char * fallback_name = new char[1];
3166+
fallback_name[0] = '\0';
3167+
ret->friendly_name = fallback_name;
3168+
}
31613169
CFRelease(str);
31623170
}
31633171

@@ -3198,6 +3206,7 @@ audiounit_create_device_from_hwdev(cubeb_device_info * ret, AudioObjectID devid,
31983206
bool
31993207
is_aggregate_device(cubeb_device_info * device_info)
32003208
{
3209+
assert(device_info->friendly_name);
32013210
return !strncmp(device_info->friendly_name, PRIVATE_AGGREGATE_DEVICE_NAME,
32023211
strlen(PRIVATE_AGGREGATE_DEVICE_NAME));
32033212
}

0 commit comments

Comments
 (0)