Repository navigation
Improve core audio resiliency - #732
Conversation
Greptile SummaryThis PR makes Direct Core Audio the default capture path and hardens its startup, readiness, device-change, and teardown lifecycle.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 250f8bfbbe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Close publication before synchronizing with the IOProc. The consumer | ||
| // still drains every packet already committed to the ring. | ||
| atomic_store_explicit(&capture->packetGateOpen, false, memory_order_release); | ||
| OSStatus status = AudioDeviceStop(capture->deviceID, capture->ioProcID); |
There was a problem hiding this comment.
Keep accepting timestamped packets until the IOProc stops
When stop races the next hardware callback, closing packetGateOpen before AudioDeviceStop causes that callback to return without publishing even if its timestamped buffer contains frames acquired before the stop boundary. ASRService.stop() explicitly marks a host-time boundary and expects the synchronously drained final packet to be trimmed to it, so this can cut the last hardware buffer—and potentially the final phoneme—from recordings. Keep publication open until AudioDeviceStop has synchronized with the IOProc, then let the pipeline discard frames after the recorded boundary.
Useful? React with 👍 / 👎.
FluidVoice PR build readyDownload FluidVoice-PR-732-250f8bfbbecc The artifact contains the ad-hoc-signed app ZIP, Xcode archive, build manifest, and installation instructions. It expires 5 days after the build. Install the app
This build has its own app identity, so its permissions are separate from the release version of FluidVoice. |
|
@greptileai re-run review with my updated responses |
…ic-dev#732 Upstream altic-dev#732 turned direct Core Audio capture on by default, deleted the duration-mismatch fallback, and reshaped the capture entry point (startPreferredAudioCapture -> startConfiguredAudioCapture, device resolution moved off-main into DirectCoreAudioLifecycleController). Conflict resolutions: - NotificationService: drop deliverAudioCaptureFallback along with the rest of the duration-mismatch machinery; keep deliverPreferredMicrophoneFallback. - ASRService: take upstream's startConfiguredAudioCapture structure and lifecycle-controller resolution, keeping the FluidVoice-only fallback announcement at both backends. The AVAudioEngine branch is now reached only when direct capture is switched off, so its comment says so. - handleDefaultInputChanged: keep the per-mode switch, adopt upstream's widened `isRunning || isStarting` guard. Also fixes a defect the merge introduced silently. Upstream's new directCoreAudioDeviceSelection() gates on `== .manual`, so it merged cleanly as an addition while routing .fluidVoiceOnly to the system default -- capturing the wrong microphone with no error, and with all 184 tests passing. Selection is now exhaustive over the mode, and .fluidVoiceOnly maps to a new .preferredUIDOrDefault case: resolveDevice now throws on an absent device rather than falling back, which would have restored the refuse-to-record behaviour this PR deliberately replaced with "prefer the pinned mic, else the default, announced". That routing rule is now a pure, nonisolated ASRService.directCaptureSelection covered by three tests -- verified to fail against the broken mapping, which no existing test caught. Local: 187 tests, 0 failures; swiftlint --strict clean. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018jnjU9kcVVRBU33Gwp8tri
…iew gaps Three findings from the review of 07c765c. Stale notification (Greptile P1). The fallback banner says "recording through <device> until your selected microphone is reconnected", but it was posted with a fresh UUID each time, so it could never be retracted -- reconnecting the mic left a notification asserting something no longer true, and repeated fallbacks stacked up one banner per recording. The identifier is now stable, and the announcer returns .doNothing / .announce / .withdraw so returning to the preferred device removes the delivered notification. Withdrawal only fires when something was actually announced, or every ordinary recording would emit a pointless removal. Unbindable preferred device (Codex P2). FluidVoice-only promises "prefer the pinned mic, else the macOS default". Resolution already covered a *missing* device, but one that is present and cannot be bound -- a multi-stream aggregate the capture helper rejects, or a device that fails to start -- threw, so the recording failed instead of degrading. It now retries once on the default and announces the substitution. Deliberately scoped to .fluidVoiceOnly: .manual and .system keep the fail-loud behaviour altic-dev#732 shipped. The shared start path is factored into startDirectCapture(selection:reason:) so both take the same route. Stale mode in Settings (Codex P2). Turning off Faster Recording Start makes the store report .manual, but the settings window's bound mode is only refreshed at launch -- so it kept saying "leaves the macOS input device unchanged" while the next recording would move it. The toggle now re-reads the mode. The stored preference is deliberately left alone, so re-enabling restores FluidVoice-only. Mutation-checked: a version that never withdraws fails the sequence test. Local: 204 tests, 0 failures; swiftlint --strict clean. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018jnjU9kcVVRBU33Gwp8tri
Description
So this is a huge PR, it touches upon a few things but the core problem this PR attempts to solve is to improve the resiliency of the core audio transcription pipeline. AVAudioEngine has been very problematic and CoreAudio is currently experimental, not well tested out but much faster. The changes part of this PR are highlighted below including the reasoning
Type of Change
Related Issue or Discussion
#709, #680
Testing
swiftlint --strict --config .swiftlint.yml SourcesTest cases
Tested out a few different use-cases across different audio input devices, constant changes, removal/additions of devices (mainly bluetooth) in order ensure that the transcription works
Screenshots / Video
Notes
Add reviewer context, rollout notes, or known tradeoffs here.