cubeb_sink: ignore null-name device when selecting

We already ignore them on listing devices. We should do the same when selecting devices. This fix a crash when opening a specific device while there is a null device in the list
This commit is contained in:
Weiyi Wang 2018-10-26 00:32:41 -04:00
parent fa0e82b812
commit b4062abc11
1 changed files with 2 additions and 1 deletions

View File

@ -56,7 +56,8 @@ CubebSink::CubebSink(std::string target_device_name) : impl(std::make_unique<Imp
const auto collection_end{collection.device + collection.count}; const auto collection_end{collection.device + collection.count};
const auto device{ const auto device{
std::find_if(collection.device, collection_end, [&](const cubeb_device_info& info) { std::find_if(collection.device, collection_end, [&](const cubeb_device_info& info) {
return target_device_name == info.friendly_name; return info.friendly_name != nullptr &&
target_device_name == info.friendly_name;
})}; })};
if (device != collection_end) { if (device != collection_end) {
output_device = device->devid; output_device = device->devid;