cubeb_sink: Skip devices without a name
Previously this would crash.
This commit is contained in:
parent
ce6d9e2e28
commit
04139e26bd
@ -13,6 +13,7 @@ namespace AudioCore {
|
||||
|
||||
struct CubebSink::Impl {
|
||||
unsigned int sample_rate = 0;
|
||||
std::vector<std::string> device_list;
|
||||
|
||||
cubeb* ctx = nullptr;
|
||||
cubeb_stream* stream = nullptr;
|
||||
@ -56,12 +57,14 @@ CubebSink::CubebSink() : impl(std::make_unique<Impl>()) {
|
||||
|
||||
for (size_t i = 0; i < collection.count; i++) {
|
||||
const cubeb_device_info& device = collection.device[i];
|
||||
device_list.emplace_back(device.friendly_name);
|
||||
if (device.friendly_name) {
|
||||
impl->device_list.emplace_back(device.friendly_name);
|
||||
|
||||
if (target_device_name && strcmp(target_device_name, device.friendly_name) == 0) {
|
||||
output_device = device.devid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cubeb_device_collection_destroy(impl->ctx, &collection);
|
||||
}
|
||||
@ -99,7 +102,7 @@ unsigned int CubebSink::GetNativeSampleRate() const {
|
||||
}
|
||||
|
||||
std::vector<std::string> CubebSink::GetDeviceList() const {
|
||||
return device_list;
|
||||
return impl->device_list;
|
||||
}
|
||||
|
||||
void CubebSink::EnqueueSamples(const s16* samples, size_t sample_count) {
|
||||
|
@ -27,8 +27,6 @@ public:
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
int device_id;
|
||||
std::vector<std::string> device_list;
|
||||
};
|
||||
|
||||
} // namespace AudioCore
|
||||
|
Loading…
Reference in New Issue
Block a user