Skip to content

Phase 2.5: extract AudioCapture protocol seam (final I/O seam) - #49

Merged
initcore0 merged 1 commit into
mainfrom
feat/core-audiocapture
Jun 23, 2026
Merged

Phase 2.5: extract AudioCapture protocol seam (final I/O seam)#49
initcore0 merged 1 commit into
mainfrom
feat/core-audiocapture

Conversation

@initcore0

Copy link
Copy Markdown
Owner

Sixth and final I/O service seam (after #44 #45 #46 #47 #48). AudioRecorder is 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

  • 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() (it was assigned in init and never read).
  • Protocol-extension convenience overloads startStreamingOnSilence(onChunk:) and stop() 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).
  • The CoreAudio AudioDevice enumeration stays concrete; SettingsView keeps using it directly — correct platform boundary.
  • The entire audio body (installTap, converter, the 16kHz Float32 non-interleaved target = the crash fix, chunk rotation, RMS/auto-gain, teardown) is byte-identical; the diff is only the class decl, the moved enum, and the dead ref.
  • Adversarial review confirmed exact equivalence on: dead-ref, overload resolution + matching defaults, Equatable addition, trailing-closure binding, device boundary, untouched audio body.
  • Tests: +5 with a FakeAudioCapture double pinning the convenience defaults. 117 → 122.
  • ROADMAP: all six I/O seams now extracted (status note added).

swift test 122/122 · ./build.sh clean (full app build).

🤖 Generated with Claude Code

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>
@initcore0
initcore0 merged commit 1b062ce into main Jun 23, 2026
3 checks passed
@initcore0
initcore0 deleted the feat/core-audiocapture branch June 23, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant