From e0da0f1f8075c439308ef74cd01c450c53fe09d7 Mon Sep 17 00:00:00 2001 From: linbo <1034003879@qq.com> Date: Tue, 25 Aug 2026 13:54:41 +0800 Subject: [PATCH] fix(microphone): list usable ALSA capture endpoints --- .../src/microphone_device_discovery.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmvr-es/devices/microphone/ffmpeg_microphone/src/microphone_device_discovery.cpp b/cmvr-es/devices/microphone/ffmpeg_microphone/src/microphone_device_discovery.cpp index 99fa3adc..df7f9e7b 100644 --- a/cmvr-es/devices/microphone/ffmpeg_microphone/src/microphone_device_discovery.cpp +++ b/cmvr-es/devices/microphone/ffmpeg_microphone/src/microphone_device_discovery.cpp @@ -2,6 +2,7 @@ #include #include +#include #include 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 listAvailableMicrophoneInputDevices() @@ -55,7 +67,7 @@ std::vector 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; }