Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(windows): after onboarding's sound check, the interpreting step no longer says VB-Cable isn't installed when it is

wquguru47895a5e4fa2
diff --git a/site/changelog.json b/site/changelog.json
index 5e9a9ed..fa10b05 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -88,6 +88,14 @@
],
"title": "按住说话键时,屏幕底部的提示条也标上“同传”,和纪要、会议记录里一样。",
"text": "从“正在听你说”到“对方已听到”,提示条上都带着“同传”,一眼看出对方听到的是译文。"
+ },
+ {
+ "kind": "fixed",
+ "platforms": [
+ "windows"
+ ],
+ "title": "引导里听过电脑声音之后,同声传译那一步不再把已装好的 VB-Cable 当成没装,按住说话也不会误报“没有虚拟麦克风”。",
+ "text": "以前偶尔会出现:第 4 步显示“安装”、托盘显示“去设置”,其实 VB-Cable 好好的。"
}
]
},
diff --git a/windows/src/Cicada/Platform.cs b/windows/src/Cicada/Platform.cs
index 63a09dc..59db9ba 100644
--- a/windows/src/Cicada/Platform.cs
+++ b/windows/src/Cicada/Platform.cs
@@ -84,54 +84,12 @@ static class AutoStart
}
/// The default playback device's name ("扬声器 (Realtek High Definition Audio)") for onboarding.
+/// Through Endpoints, never a second [ComImport] MMDeviceEnumerator: the enumerator is one COM object
+/// per process, and while an RCW of another class for it lives, `new` of Endpoints' class throws
+/// InvalidCastException, so the virtual cable looked uninstalled after onboarding's sound step.
static class AudioDevice
{
- public static string? DefaultName()
- {
- try
- {
- var enumerator = (IMMDeviceEnumerator)new MMDeviceEnumerator();
- Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(0 /* eRender */, 1 /* eMultimedia */, out var device));
- Marshal.ThrowExceptionForHR(device.OpenPropertyStore(0 /* STGM_READ */, out var store));
- var key = new PropertyKey { fmtid = new Guid("a45c254e-df1c-4efd-8020-67d146a850e0"), pid = 14 }; // PKEY_Device_FriendlyName
- Marshal.ThrowExceptionForHR(store.GetValue(ref key, out var value));
- var name = value.vt == 31 /* VT_LPWSTR */ ? Marshal.PtrToStringUni(value.pointer) : null;
- PropVariantClear(ref value);
- return name;
- }
- catch (Exception e) { Log.Debug($"audio device: name unavailable {e.GetType().Name}"); return null; }
- }
-
- [ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumerator { }
-
- [ComImport, Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- interface IMMDeviceEnumerator
- {
- [PreserveSig] int EnumAudioEndpoints(int dataFlow, int stateMask, out IntPtr devices);
- [PreserveSig] int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice device);
- }
-
- [ComImport, Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- interface IMMDevice
- {
- [PreserveSig] int Activate(ref Guid iid, int clsCtx, IntPtr activationParams, [MarshalAs(UnmanagedType.IUnknown)] out object iface);
- [PreserveSig] int OpenPropertyStore(int access, out IPropertyStore store);
- }
-
- [ComImport, Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- interface IPropertyStore
- {
- [PreserveSig] int GetCount(out int count);
- [PreserveSig] int GetAt(int index, out PropertyKey key);
- [PreserveSig] int GetValue(ref PropertyKey key, out PropVariant value);
- }
-
- [StructLayout(LayoutKind.Sequential)] struct PropertyKey { public Guid fmtid; public int pid; }
-
- [StructLayout(LayoutKind.Explicit, Size = 24)]
- struct PropVariant { [FieldOffset(0)] public ushort vt; [FieldOffset(8)] public IntPtr pointer; }
-
- [DllImport("ole32.dll")] static extern int PropVariantClear(ref PropVariant value);
+ public static string? DefaultName() => Endpoints.Default(Endpoints.Flow.Render)?.Name;
}
/// The meeting apps reading a microphone now (MicUse in Cicada.Core reads the entries): what