summaryrefslogtreecommitdiffhomepage
path: root/src/raudio.c
diff options
context:
space:
mode:
authorRob Loach <[email protected]>2023-01-27 13:24:03 -0500
committerGitHub <[email protected]>2023-01-27 19:24:03 +0100
commit83ff7b246613c57dd5703d24965b4036332a100f (patch)
treecf15517ca3c4a3da4ed0a3aaad0cf2d599bf47b3 /src/raudio.c
parent81ca2f0bf36e59623084d583f3e26c3709b96a27 (diff)
downloadraylib-83ff7b246613c57dd5703d24965b4036332a100f.tar.gz
raylib-83ff7b246613c57dd5703d24965b4036332a100f.zip
ADDED: `IsShaderReady()`, `IsImageReady()`, `IsFontReady()`, `IsWaveReady()`, `IsSoundReady()`, `IsMusicReady()` (#2892)
These IsReady() functions provide a method in order to verify whether or not the object was loaded successfully. They're useful to make sure the assets are there prior to using them.
Diffstat (limited to 'src/raudio.c')
-rw-r--r--src/raudio.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/raudio.c b/src/raudio.c
index 34ab0702..46d8223d 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -836,6 +836,12 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
return wave;
}
+// Checks if wave data is ready
+bool IsWaveReady(Wave wave)
+{
+ return wave.data != NULL;
+}
+
// Load sound from file
// NOTE: The entire file is loaded to memory to be played (no-streaming)
Sound LoadSound(const char *fileName)
@@ -892,6 +898,12 @@ Sound LoadSoundFromWave(Wave wave)
return sound;
}
+// Checks if a sound is ready
+bool IsSoundReady(Sound sound)
+{
+ return sound.stream.buffer != NULL;
+}
+
// Unload wave data
void UnloadWave(Wave wave)
{
@@ -1614,6 +1626,12 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
return music;
}
+// Checks if a music stream is ready
+bool IsMusicReady(Music music)
+{
+ return music.ctxData != NULL;
+}
+
// Unload music stream
void UnloadMusicStream(Music music)
{
@@ -1967,6 +1985,12 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
return stream;
}
+// Checks if an audio stream is ready
+RLAPI bool IsAudioStreamReady(AudioStream stream)
+{
+ return stream.buffer != NULL;
+}
+
// Unload audio stream and free memory
void UnloadAudioStream(AudioStream stream)
{