[refactor] centralize mic ownership in a single MicCoordinator#96
Merged
Conversation
The meeting, Settings mic test, and voice typing each kept their own AtomicBool with hand-written pairwise exclusion checks — and the matrix had holes: voice typing checked nothing, so push-to-talk during a live meeting opened a second CoreAudio input stream that could silently kill the meeting's capture. The two stop paths also disagreed: meetings used a per-session gate + bounded join while voice typing joined unbounded on a shared flag (hang risk + the exact thread-revival race the meeting code was built to prevent). New capture.rs owns the whole story: MicCoordinator (managed state) guarantees at most one live capture session, with priority-based preemption (Meeting > VoiceTyping > MicTest) and idempotent restarts; CaptureSession unifies per-session gates + bounded-join teardown; the duplicated metered-session/usage-billing plumbing is now one function. Fixes along the way: - voice typing during a meeting is now refused (surfaced in the overlay) instead of corrupting the meeting's capture - stop_voice_typing can no longer hang on a wedged device teardown - a failed mic-test start no longer leaks its flag (which permanently refused later tests) - meeting start now joins the preempted mic test before opening the device (was a brief double-stream window) Also dedupes the app-config file path/read/write helpers and clears all outstanding clippy warnings (type alias in diarize, redundant casts in permissions, manual split_once, redundant closure).
9dda240 to
943d3e8
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
The meeting, Settings mic test, and voice typing each kept their own
AtomicBoolwith hand-written pairwise exclusion checks — and the matrix had holes. This PR introducescapture.rsas the single source of truth for "who owns the mic":MicCoordinator(Tauri managed state) guarantees at most one live capture session, with priority-based preemption (Meeting > VoiceTyping > MicTest) and idempotent restarts.CaptureSessionunifies the per-session gate (prevents a wedged old thread from being revived by a later start flipping a shared flag) + bounded-join teardown (1.5 s grace, then detach) — previously two divergent implementations.usage://sttbilling plumbing (commands.rs + voice_typing.rs copies) is now onerun_metered_session.MeetingStateshrinks from 6 fields to 2;VoiceTypingStateis deleted entirely. The IPC surface is unchanged (same command names/args).Bugs fixed along the way
stop_voice_typingjoined unbounded on a shared flag — hang risk on a wedged device teardown, plus the exact thread-revival race the meeting code was built to prevent.test_running=true, permanently refusing later tests.Also
app_config_file/read_config_file/write_config_file).split_once, redundant closure).Behavior change (user-visible)
Holding push-to-talk while a meeting is recording now shows an error in the overlay instead of silently corrupting the meeting's transcription.
Testing
cargo clippy: 0 warnings (was 5)cargo test --lib: 13 passedvitest: 96 passed