Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
fix wired microphones in clamshell mode
altic-dev12489d999307
diff --git a/Info.plist b/Info.plistindex d8fcf72b..4770b0ef 100644--- a/Info.plist+++ b/Info.plist@@ -13,9 +13,9 @@<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string><key>CFBundleVersion</key>- <string>19</string>+ <string>20</string><key>CFBundleShortVersionString</key>- <string>1.6.8</string>+ <string>1.6.9</string><key>LSMinimumSystemVersion</key><string>$(MACOSX_DEPLOYMENT_TARGET)</string><key>LSApplicationCategoryType</key>diff --git a/Sources/Fluid/Services/AudioDeviceService.swift b/Sources/Fluid/Services/AudioDeviceService.swiftindex 4cd86152..c9669fa1 100644--- a/Sources/Fluid/Services/AudioDeviceService.swift+++ b/Sources/Fluid/Services/AudioDeviceService.swift@@ -15,12 +15,15 @@ import IOKit.pwr_mgtnonisolated enum AudioDevice {struct Device: Identifiable, Hashable {+ static let externalMicrophoneDataSourceID: UInt32 = 0x656d6963 // 'emic'+let id: AudioObjectIDlet uid: Stringlet name: Stringlet hasInput: Boollet hasOutput: Boollet transportType: UInt32+ let inputDataSourceID: UInt32?let isAlive: Boolinit(@@ -30,6 +33,7 @@ nonisolated enum AudioDevice {hasInput: Bool,hasOutput: Bool,transportType: UInt32 = kAudioDeviceTransportTypeUnknown,+ inputDataSourceID: UInt32? = nil,isAlive: Bool = true) {self.id = id@@ -38,6 +42,7 @@ nonisolated enum AudioDevice {self.hasInput = hasInputself.hasOutput = hasOutputself.transportType = transportType+ self.inputDataSourceID = inputDataSourceIDself.isAlive = isAlive}@@ -49,6 +54,12 @@ nonisolated enum AudioDevice {var isBuiltIn: Bool {self.transportType == kAudioDeviceTransportTypeBuiltIn}++ /// Analog headsets use the Mac's built-in audio transport, but Core Audio+ /// identifies their selected input source as an external microphone.+ var isUnavailableWhenClamshellClosed: Bool {+ self.isBuiltIn && self.inputDataSourceID != Self.externalMicrophoneDataSourceID+ }}private struct InputLivenessKey: Hashable {@@ -134,6 +145,11 @@ nonisolated enum AudioDevice {selector: kAudioDevicePropertyTransportType,scope: kAudioObjectPropertyScopeGlobal) ?? kAudioDeviceTransportTypeUnknown+ let inputDataSourceID = hasIn ? self.getUInt32Property(+ devId,+ selector: kAudioDevicePropertyDataSource,+ scope: kAudioObjectPropertyScopeInput+ ) : nildevices.append(Device(id: devId,@@ -142,6 +158,7 @@ nonisolated enum AudioDevice {hasInput: hasIn,hasOutput: hasOut,transportType: transportType,+ inputDataSourceID: inputDataSourceID,isAlive: cachedInputLiveness[InputLivenessKey(id: devId, uid: uid)] ?? true@@ -177,6 +194,7 @@ nonisolated enum AudioDevice {hasInput: device.hasInput,hasOutput: device.hasOutput,transportType: device.transportType,+ inputDataSourceID: device.inputDataSourceID,isAlive: liveness[InputLivenessKey(id: device.id, uid: device.uid)] ?? true)}@@ -251,7 +269,8 @@ nonisolated enum AudioDevice {/// alive while a MacBook is closed. Treat it as unavailable in that state,/// while leaving external and virtual inputs eligible.static func isInputDeviceUsable(_ device: Device) -> Bool {- self.isInputDeviceAlive(device) && (device.isBuiltIn == false || ClamshellState.isClosed == false)+ self.isInputDeviceAlive(device) &&+ (device.isUnavailableWhenClamshellClosed == false || ClamshellState.isClosed == false)}/// Get output device by UID without affecting system settingsdiff --git a/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swift b/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swiftindex c32fac79..3c2d2e78 100644--- a/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swift+++ b/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swift@@ -414,7 +414,7 @@ final class MicrophonePreferenceCoordinator: ObservableObject {clamshellClosed: Bool) -> Bool {guard self.settings.suppressedMicrophoneUIDs.contains(device.uid) == false else { return false }- guard clamshellClosed == false || device.isBuiltIn == false else { return false }+ guard clamshellClosed == false || device.isUnavailableWhenClamshellClosed == false else { return false }return self.devices.isInputDeviceUsable(device)}}diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex 41758354..0320ce47 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -1329,6 +1329,37 @@ final class HotkeyShortcutTests: XCTestCase {}}+ @MainActor+ func testClamshellKeepsBuiltInTransportExternalMicrophoneAvailable() throws {+ try self.withRestoredDefaults(keys: [+ self.microphoneSelectionModeKey,+ self.preferredInputDeviceUIDKey,+ self.microphonePriorityKey,+ self.microphoneSelectionMigrationVersionKey,+ ]) {+ let wiredHeadset = Self.device(+ uid: "wired-headset",+ name: "External Microphone",+ transportType: kAudioDeviceTransportTypeBuiltIn,+ inputDataSourceID: AudioDevice.Device.externalMicrophoneDataSourceID+ )+ SettingsStore.shared.microphonePriority = [+ .init(uid: wiredHeadset.uid, name: wiredHeadset.name),+ ]+ SettingsStore.shared.microphoneSelectionMode = .manual+ SettingsStore.shared.microphoneSelectionMigrationVersion = 4+ let devices = FakeAudioDeviceManager(+ inputs: [wiredHeadset],+ defaultInputUID: wiredHeadset.uid,+ isClamshellClosed: true+ )+ let coordinator = MicrophonePreferenceCoordinator(settings: .shared, devices: devices)++ XCTAssertTrue(wiredHeadset.isBuiltIn)+ XCTAssertEqual(coordinator.inputDeviceForCapture(), wiredHeadset)+ }+ }+func testNewMicrophoneEntersSecondAndStaysAfterDisconnecting() throws {try self.withRestoredDefaults(keys: [self.preferredInputDeviceUIDKey,@@ -1420,7 +1451,8 @@ final class HotkeyShortcutTests: XCTestCase {private static func device(uid: String,name: String,- transportType: UInt32 = kAudioDeviceTransportTypeUnknown+ transportType: UInt32 = kAudioDeviceTransportTypeUnknown,+ inputDataSourceID: UInt32? = nil) -> AudioDevice.Device {AudioDevice.Device(id: AudioObjectID(abs(uid.hashValue % 100_000) + 1),@@ -1428,7 +1460,8 @@ final class HotkeyShortcutTests: XCTestCase {name: name,hasInput: true,hasOutput: false,- transportType: transportType+ transportType: transportType,+ inputDataSourceID: inputDataSourceID)}