fix(microphone): list usable ALSA capture endpoints
This commit is contained in:
parent
36c74af588
commit
e0da0f1f80
@ -2,6 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
extern "C" {
|
||||
@ -26,6 +27,17 @@ struct DeviceListDeleter {
|
||||
}
|
||||
};
|
||||
|
||||
bool isFfmpegCaptureEndpoint(const char* device_name)
|
||||
{
|
||||
constexpr std::string_view kPlugHardwarePrefix = "plughw:";
|
||||
if (!device_name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string_view name(device_name);
|
||||
return name.compare(0, kPlugHardwarePrefix.size(), kPlugHardwarePrefix) == 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::vector<MicrophoneInputDeviceInfo> listAvailableMicrophoneInputDevices()
|
||||
@ -55,7 +67,7 @@ std::vector<MicrophoneInputDeviceInfo> listAvailableMicrophoneInputDevices()
|
||||
|
||||
for (int index = 0; index < device_list->nb_devices; ++index) {
|
||||
const AVDeviceInfo* source = device_list->devices[index];
|
||||
if (!source || !source->device_name || source->device_name[0] == '\0') {
|
||||
if (!source || !isFfmpegCaptureEndpoint(source->device_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user