diff options
| author | Ray <[email protected]> | 2021-05-07 15:38:13 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2021-05-07 15:38:13 +0200 |
| commit | b62c86572e58c95e23c19d03e9b0bdacfa214f80 (patch) | |
| tree | dbffb580833b21fb37326c9e59a8fe104475eaf9 /src/raudio.c | |
| parent | c82d9cb89a4aec4485441887f8b74fff06494be5 (diff) | |
| download | raylib-b62c86572e58c95e23c19d03e9b0bdacfa214f80.tar.gz raylib-b62c86572e58c95e23c19d03e9b0bdacfa214f80.zip | |
REVIEWED: raudio_standalone #1752
Diffstat (limited to 'src/raudio.c')
| -rw-r--r-- | src/raudio.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/raudio.c b/src/raudio.c index 2b6b0a19..5db2407a 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -385,6 +385,10 @@ static Wave LoadMP3(const unsigned char *fileData, unsigned int fileSize); // #if defined(RAUDIO_STANDALONE) static bool IsFileExtension(const char *fileName, const char *ext); // Check file extension +static const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes the dot: .png) +static bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal +static const char *TextToLower(const char *text); // Get lower case version of provided string + static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) static bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write) static bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated @@ -1587,11 +1591,11 @@ void StopMusicStream(Music music) // Update (re-fill) music buffers if data already processed void UpdateMusicStream(Music music) { - if (music.stream.buffer == NULL) - return; + if (music.stream.buffer == NULL) return; - if (music.ctxType == MUSIC_MODULE_XM) - jar_xm_set_max_loop_count(music.ctxData, music.looping ? 0 : 1); +#if defined(SUPPORT_FILEFORMAT_XM) + if (music.ctxType == MUSIC_MODULE_XM) jar_xm_set_max_loop_count(music.ctxData, music.looping ? 0 : 1); +#endif bool streamEnding = false; @@ -2327,6 +2331,48 @@ static bool IsFileExtension(const char *fileName, const char *ext) return result; } +// Get pointer to extension for a filename string (includes the dot: .png) +static const char *GetFileExtension(const char *fileName) +{ + const char *dot = strrchr(fileName, '.'); + + if (!dot || dot == fileName) return NULL; + + return dot; +} + +// Check if two text string are equal +// REQUIRES: strcmp() +static bool TextIsEqual(const char *text1, const char *text2) +{ + bool result = false; + + if (strcmp(text1, text2) == 0) result = true; + + return result; +} + +// Get lower case version of provided string +// REQUIRES: tolower() +static const char *TextToLower(const char *text) +{ + #define MAX_TEXT_BUFFER_LENGTH 1024 + + static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; + + for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) + { + if (text[i] != '\0') + { + buffer[i] = (char)tolower(text[i]); + //if ((text[i] >= 'A') && (text[i] <= 'Z')) buffer[i] = text[i] + 32; + } + else { buffer[i] = '\0'; break; } + } + + return buffer; +} + // Load data from file into a buffer static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead) { |
