Overview
IAudioSystem is the abstract interface for audio subsystems in ReXGlue. It provides dependency injection for different audio backends, with SDL as the primary implementation.
Header: rex/system/interfaces/audio.h
Namespace: rex::system
Interface Methods
Setup
kernel_state- Pointer to the kernel state manager
X_STATUS - Status code indicating success or failure
Shutdown
Concrete Implementation
SDL Audio System
Class:rex::audio::sdl::SDLAudioSystem
Header: rex/audio/sdl/sdl_audio_system.h
SDL-based audio implementation providing cross-platform audio support.
Base AudioSystem Class
The SDL implementation extendsrex::audio::AudioSystem, which provides:
Key Members:
memory()- Access to memory subsystemprocessor()- Access to CPU processorxma_decoder()- XMA audio decoder instance
Setup(kernel_state)- Initialize audio systemShutdown()- Shutdown audio systemRegisterClient(callback, callback_arg, out_index)- Register audio clientUnregisterClient(index)- Unregister audio clientSubmitFrame(index, samples_ptr)- Submit audio frame for playbackPause()/Resume()- Pause and resume audio playbackSave(stream)/Restore(stream)- Save and restore state
kMaximumClientCount = 8- Maximum number of simultaneous audio clients
Example Usage
Initializing SDL Audio System
Registering an Audio Client
Pausing and Resuming Audio
Using XMA Decoder
Audio Driver Interface
The audio system creates and managesAudioDriver instances for each client:
Thread Safety
The audio system usesrex::thread::global_critical_region for thread-safe access to client management and audio frame submission.
See Also
- KernelState - Kernel state management
- IGraphicsSystem - Graphics subsystem interface
- IInputSystem - Input subsystem interface