|
Migrated production code (main.cc) to use AudioEngine instead of directly
calling synth_init() and tracker_init(), eliminating initialization order
dependencies in the demo entry point.
Changes:
- Added #include "audio/audio_engine.h" to main.cc
- Replaced synth_init() + tracker_init() with AudioEngine::init()
- Replaced tracker_update(g_music_time) with g_audio_engine.update(g_music_time)
- Preserved direct synth calls (synth_register_spectrogram, synth_get_output_peak)
as these are valid API usage
Results:
- All 20 tests pass (100% pass rate)
- Demo runs successfully without crashes
- Initialization order fragility eliminated in production code
- Test suite time: 8.13s (unchanged)
Known Technical Debt (deferred to Phase 4):
- audio_init() still calls synth_init() internally for backwards compatibility
- This causes double initialization (harmless but fragile)
- Some tests rely on this behavior
- Will be cleaned up in Phase 4 with other compatibility shims
handoff(Claude): Completed Task #56 Phase 3 - production code now uses AudioEngine.
Phase 4 (Cleanup) remains: remove old global functions, update remaining tests,
remove backwards compatibility shims, update documentation.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
Phase 1)
Implements Phase 1 of the audio lifecycle refactor to eliminate initialization
order dependencies between synth and tracker.
New Components:
1. SpectrogramResourceManager (src/audio/spectrogram_resource_manager.{h,cc})
- Centralized resource loading and ownership
- Lazy loading: resources registered but not loaded until needed
- Handles both asset spectrograms and procedural notes
- Clear ownership: assets borrowed, procedurals owned
- Optional cache eviction under DEMO_ENABLE_CACHE_EVICTION flag
2. AudioEngine (src/audio/audio_engine.{h,cc})
- Unified audio subsystem manager
- Single initialization point eliminates order dependencies
- Manages synth, tracker, and resource manager lifecycle
- Timeline seeking API for debugging (!STRIP_ALL)
- Clean API: init(), shutdown(), reset(), seek()
Features:
- Lazy loading strategy with manual preload API
- Reset functionality for timeline seeking
- Zero impact on production builds
- Debug-only seeking support
Testing:
- Comprehensive test suite (test_audio_engine.cc)
- Tests lifecycle, resource loading, reset, seeking
- All 20 tests passing (100% pass rate)
Bug Fixes:
- Fixed infinite recursion in AudioEngine::tracker_reset()
Integration:
- Added to CMakeLists.txt audio library
- No changes to existing code (backward compatible)
Binary Size Impact: ~700 bytes (within budget)
Next: Phase 2 (Test Migration) - Update existing tests to use AudioEngine
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|