diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-04 13:08:13 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-04 13:08:13 +0100 |
| commit | c4888bea71326f7a69e8214af0d9c2a62a60b887 (patch) | |
| tree | dd1e71be51893414c590db8a7be578ddfd6232f0 /src/audio/miniaudio_backend.h | |
| parent | f64f842bb0dabd89308e2378e56358bc8abdd653 (diff) | |
feat(audio): Implement audio backend abstraction (Task #51.1)
Created interface-based audio backend system to enable testing without
hardware. This is the foundation for robust tracker timing verification.
Changes:
- Created AudioBackend interface with init/start/shutdown methods
- Added test-only hooks: on_voice_triggered() and on_frames_rendered()
- Moved miniaudio implementation to MiniaudioBackend class
- Refactored audio.cc to use backend abstraction with auto-fallback
- Added time tracking to synth.cc (elapsed time from rendered frames)
- Created test_audio_backend.cc to verify backend injection works
- Fixed audio test linking to include util/procedural dependencies
All test infrastructure guarded by #if !defined(STRIP_ALL) for zero
size impact on final build. Production path unchanged, 100% backward
compatible. All 13 tests pass.
handoff(Claude): Task #51.1 complete, audio backend abstraction ready
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/audio/miniaudio_backend.h')
| -rw-r--r-- | src/audio/miniaudio_backend.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/audio/miniaudio_backend.h b/src/audio/miniaudio_backend.h new file mode 100644 index 0000000..d46a0c5 --- /dev/null +++ b/src/audio/miniaudio_backend.h @@ -0,0 +1,31 @@ +// This file is part of the 64k demo project. +// It implements the production audio backend using miniaudio. +// This is the default backend for the final build. + +#pragma once + +#include "audio_backend.h" +#include "miniaudio.h" + +// Production audio backend using miniaudio library +// Manages real hardware audio device and playback +class MiniaudioBackend : public AudioBackend { + public: + MiniaudioBackend(); + ~MiniaudioBackend() override; + + void init() override; + void start() override; + void shutdown() override; + + // Get the underlying miniaudio device (for internal use) + ma_device* get_device() { return &device_; } + + private: + ma_device device_; + bool initialized_; + + // Static callback required by miniaudio C API + static void audio_callback(ma_device* pDevice, void* pOutput, + const void* pInput, ma_uint32 frameCount); +}; |
