Skip to content

[Option B] Consolidate ThreadedStrategy implementation #25

@danieljsinclair

Description

@danieljsinclair

Issue

Consolidate ThreadedAudioMode + ThreadedRenderer into unified ThreadedStrategy.

Background

Current architecture has coupled pair that cannot be swapped independently:

  • ThreadedAudioMode: Handles lifecycle and simulation updates
  • ThreadedRenderer: Handles rendering with cursor-chasing buffer

This creates unnecessary complexity and violates OCP.

Goal

Create ThreadedStrategy that unifies lifecycle and rendering:

  • Single class implementing IAudioStrategy
  • Uses IAudioHardwareProvider for platform-specific audio
  • Handles cursor-chasing logic internally
  • Manages circular buffer state

Implementation Plan

  1. Create ThreadedStrategy.h/cpp implementing IAudioStrategy
  2. Merge ThreadedAudioMode lifecycle methods into ThreadedStrategy
  3. Merge ThreadedRenderer rendering methods into ThreadedStrategy
  4. Inject IAudioHardwareProvider instead of using AudioUnit directly
  5. Manage CircularBuffer internally
  6. Maintain cursor-chasing diagnostics

Acceptance Criteria

  1. ThreadedStrategy.h/cpp created implementing IAudioStrategy
  2. Combines ThreadedAudioMode + ThreadedRenderer functionality
  3. Uses IAudioHardwareProvider for audio hardware access
  4. Maintains all cursor-chasing behavior (pre-fill, cursor tracking, underrun handling)
  5. All tests pass (existing ThreadedRenderer tests)
  6. Buffer math verified identical via deterministic tests
  7. Clean build with no warnings

Testing

  • All existing ThreadedRenderer unit tests pass
  • All existing ThreadedAudioMode unit tests pass
  • Simulator-level audio tests produce identical output
  • No behavioral changes (audio sounds identical)

Dependencies

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions