* Audio device management functions. */
| 10 | * Audio device management functions. |
| 11 | */ |
| 12 | class AudioDevice { |
| 13 | public: |
| 14 | /** |
| 15 | * Initialize audio device and context. |
| 16 | * |
| 17 | * @param lateInit Whether or not to post-pone initializing the context. |
| 18 | * |
| 19 | * @throws raylib::RaylibException Throws if the AudioDevice failed to initialize. |
| 20 | */ |
| 21 | explicit AudioDevice(bool lateInit = false) { |
| 22 | if (!lateInit) { |
| 23 | Init(); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | AudioDevice(const AudioDevice&) = delete; |
| 28 | AudioDevice& operator=(const AudioDevice&) = delete; |
| 29 | |
| 30 | /** |
| 31 | * Close the audio device and context. |
| 32 | */ |
| 33 | ~AudioDevice() { Close(); } |
| 34 | |
| 35 | /** |
| 36 | * Initialize audio device and context. |
| 37 | * |
| 38 | * @throws raylib::RaylibException Throws if the AudioDevice failed to initialize. |
| 39 | */ |
| 40 | static void Init() { |
| 41 | ::InitAudioDevice(); |
| 42 | if (!IsReady()) { |
| 43 | throw RaylibException("Failed to initialize AudioDevice"); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Close the audio device and context. |
| 49 | */ |
| 50 | static void Close() { ::CloseAudioDevice(); } |
| 51 | |
| 52 | /** |
| 53 | * Check if audio device has been initialized successfully. |
| 54 | */ |
| 55 | static bool IsReady() { return ::IsAudioDeviceReady(); } |
| 56 | |
| 57 | /** |
| 58 | * Set master volume (listener). |
| 59 | * |
| 60 | * @param volume The desired volume to set. |
| 61 | */ |
| 62 | AudioDevice& SetVolume(float volume) { |
| 63 | ::SetMasterVolume(volume); |
| 64 | return *this; |
| 65 | } |
| 66 | }; |
| 67 | } // namespace raylib |
| 68 | |
| 69 | using RAudioDevice = raylib::AudioDevice; |
nothing calls this directly
no outgoing calls
no test coverage detected