MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / AudioStreamUnmanaged

Class AudioStreamUnmanaged

include/AudioStreamUnmanaged.hpp:16–195  ·  view source on GitHub ↗

* An AudioStream that is not managed by C++ RAII. * * Make sure to Unload() this if needed, otherwise use raylib::AudioStream. * * @see raylib::AudioStream */

Source from the content-addressed store, hash-verified

14 * @see raylib::AudioStream
15 */
16class AudioStreamUnmanaged : public ::AudioStream {
17public:
18 /**
19 * Creates an AudioStreamUnmanaged from an existing AudioStream struct.
20 */
21 AudioStreamUnmanaged(const ::AudioStream& stream) : ::AudioStream(stream) {}
22
23 /**
24 * Creates an AudioStreamUnmanaged from its components.
25 */
26 AudioStreamUnmanaged(
27 rAudioBuffer* buffer = nullptr,
28 rAudioProcessor* processor = nullptr,
29 unsigned int sampleRate = 0,
30 unsigned int sampleSize = 0,
31 unsigned int channels = 0)
32 : ::AudioStream{buffer, processor, sampleRate, sampleSize, channels} {}
33
34 /**
35 * Init audio stream (to stream raw audio PCM data).
36 *
37 * @throws raylib::RaylibException Throws if the AudioStream failed to load.
38 */
39 AudioStreamUnmanaged(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels = 2) {
40 Load(sampleRate, sampleSize, channels);
41 }
42
43 GETTER(rAudioBuffer*, Buffer, buffer)
44 GETTER(rAudioProcessor*, Processor, processor)
45 GETTER(unsigned int, SampleRate, sampleRate)
46 GETTER(unsigned int, SampleSize, sampleSize)
47 GETTER(unsigned int, Channels, channels)
48
49 AudioStreamUnmanaged& operator=(const ::AudioStream& stream) {
50 set(stream);
51 return *this;
52 }
53
54 /**
55 * Load audio stream (to stream raw audio PCM data).
56 *
57 * Does NOT call Unload() first — that is the responsibility of the managed class.
58 *
59 * @throws raylib::RaylibException Throws if the AudioStream failed to load.
60 */
61 void Load(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels = 2) {
62 set(::LoadAudioStream(sampleRate, sampleSize, channels));
63 if (!IsValid()) {
64 throw RaylibException("Failed to load audio stream");
65 }
66 }
67
68 /**
69 * Unload audio stream and free memory.
70 */
71 void Unload() {
72 // Protect against calling UnloadAudioStream() twice.
73 if (buffer != nullptr) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected