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 {
|
struct CubebSink::Impl {
|
||||||
unsigned int sample_rate = 0;
|
unsigned int sample_rate = 0;
|
||||||
|
std::vector<std::string> device_list;
|
||||||
|
|
||||||
cubeb* ctx = nullptr;
|
cubeb* ctx = nullptr;
|
||||||
cubeb_stream* stream = nullptr;
|
cubeb_stream* stream = nullptr;
|
||||||
@ -56,10 +57,12 @@ CubebSink::CubebSink() : impl(std::make_unique<Impl>()) {
|
|||||||
|
|
||||||
for (size_t i = 0; i < collection.count; i++) {
|
for (size_t i = 0; i < collection.count; i++) {
|
||||||
const cubeb_device_info& device = collection.device[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) {
|
if (target_device_name && strcmp(target_device_name, device.friendly_name) == 0) {
|
||||||
output_device = device.devid;
|
output_device = device.devid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +102,7 @@ unsigned int CubebSink::GetNativeSampleRate() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> CubebSink::GetDeviceList() 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) {
|
void CubebSink::EnqueueSamples(const s16* samples, size_t sample_count) {
|
||||||
|
@ -27,8 +27,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
std::unique_ptr<Impl> impl;
|
std::unique_ptr<Impl> impl;
|
||||||
int device_id;
|
|
||||||
std::vector<std::string> device_list;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace AudioCore
|
} // namespace AudioCore
|
||||||
|
Loading…
Reference in New Issue
Block a user