Phase 2.5: extract AudioCapture protocol seam (final I/O seam) - #49
Merged
Conversation
Sixth and last I/O service seam. AudioRecorder is the largest/most fragile service (~720 LOC AVAudioEngine + AVAudioConverter + CoreAudio; the file where the live-chunks crash lived), so this was done carefully and adversarially reviewed. - AudioCapture protocol (autoGainEnabled + onStateChanged/onLevelChanged + selectDevice + start + startStreaming + startStreamingOnSilence + stop). AudioRecorder conforms. - RecorderState nested enum -> top-level, Equatable, in OpenWhispCore. - Removed the dead `weak var appState` back-ref + init(appState:) -> override init() (appState was assigned in init and never read). - Protocol-extension convenience overloads: startStreamingOnSilence(onChunk:) and stop() forward the concrete recorder's exact VAD defaults (0.75/0.35/12.0/0.018) / nil completion, so AppState's call sites are unchanged. Only the convenience overloads match those calls through the protocol type (verified unambiguous). - The CoreAudio AudioDevice enumeration (availableInputs, AudioDeviceID) stays concrete and SettingsView keeps using it directly — correct platform boundary. - The entire audio body (installTap, converter, 16kHz Float32 non-interleaved target = the crash fix, chunk rotation, RMS/auto-gain, teardown) is byte- identical; diff is only the class decl, the moved enum, and the dead ref. - Adversarial review confirmed exact equivalence on all of: dead-ref, overload resolution + matching defaults, Equatable addition, trailing-closure binding, device boundary, and the untouched audio body. - Tests: +5 with a FakeAudioCapture double that pins the convenience defaults and unlocks AppState session tests. 117 -> 122. - ROADMAP: AudioCapture done; all six I/O seams now extracted (status note added). swift test 122/122; ./build.sh clean (full app build, not just core). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Sixth and final I/O service seam (after #44 #45 #46 #47 #48).
AudioRecorderis the largest and most fragile service (~720 LOC AVAudioEngine + AVAudioConverter + CoreAudio — the file the live-chunks crash lived in), so this was done carefully and adversarially reviewed.Changes
AudioCaptureprotocol (autoGainEnabled,onStateChanged/onLevelChanged,selectDevice,start,startStreaming,startStreamingOnSilence,stop) —AudioRecorderconforms.RecorderStatenested enum → top-level,Equatable, in OpenWhispCore.weak var appStateback-ref +init(appState:)→override init()(it was assigned in init and never read).startStreamingOnSilence(onChunk:)andstop()forward the recorder's exact VAD defaults (0.75/0.35/12.0/0.018) / nil completion, so AppState's call sites are unchanged — only those overloads match the calls through the protocol type (verified unambiguous).AudioDeviceenumeration stays concrete; SettingsView keeps using it directly — correct platform boundary.Equatableaddition, trailing-closure binding, device boundary, untouched audio body.FakeAudioCapturedouble pinning the convenience defaults. 117 → 122.swift test122/122 ·./build.shclean (full app build).🤖 Generated with Claude Code