raudio.c tabs to spaces

This commit is contained in:
nezvers 2021-02-22 20:20:24 +02:00
parent 1afee2f4d1
commit efd083a638

View File

@ -1299,58 +1299,58 @@ Music LoadMusicStream(const char *fileName)
// extension including period ".mod" // extension including period ".mod"
Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize){ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize){
Music music = { 0 }; Music music = { 0 };
bool musicLoaded = false; bool musicLoaded = false;
char fileExtLower[16] = { 0 }; char fileExtLower[16] = { 0 };
strcpy(fileExtLower, TextToLower(fileType)); strcpy(fileExtLower, TextToLower(fileType));
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_XM) #if defined(SUPPORT_FILEFORMAT_XM)
if (TextIsEqual(fileExtLower, ".xm")) if (TextIsEqual(fileExtLower, ".xm"))
{ {
jar_xm_context_t *ctxXm = NULL; jar_xm_context_t *ctxXm = NULL;
int result = jar_xm_create_context_safe(&ctxXm, data, dataSize, 48000); int result = jar_xm_create_context_safe(&ctxXm, data, dataSize, 48000);
if (result == 0) // XM AUDIO.System.context created successfully if (result == 0) // XM AUDIO.System.context created successfully
{ {
music.ctxType = MUSIC_MODULE_XM; music.ctxType = MUSIC_MODULE_XM;
jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops
// NOTE: Only stereo is supported for XM // NOTE: Only stereo is supported for XM
music.stream = InitAudioStream(48000, 16, 2); music.stream = InitAudioStream(48000, 16, 2);
music.sampleCount = (unsigned int)jar_xm_get_remaining_samples(ctxXm)*2; // 2 channels music.sampleCount = (unsigned int)jar_xm_get_remaining_samples(ctxXm)*2; // 2 channels
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
jar_xm_reset(ctxXm); // make sure we start at the beginning of the song jar_xm_reset(ctxXm); // make sure we start at the beginning of the song
music.ctxData = ctxXm; music.ctxData = ctxXm;
musicLoaded = true; musicLoaded = true;
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if defined(SUPPORT_FILEFORMAT_MOD)
else if (TextIsEqual(fileExtLower, ".mod")) else if (TextIsEqual(fileExtLower, ".mod"))
{ {
jar_mod_context_t *ctxMod = RL_MALLOC(sizeof(jar_mod_context_t)); jar_mod_context_t *ctxMod = RL_MALLOC(sizeof(jar_mod_context_t));
int result = 0; int result = 0;
jar_mod_init(ctxMod); jar_mod_init(ctxMod);
// copy data to allocated memory for default UnloadMusicStream // copy data to allocated memory for default UnloadMusicStream
unsigned char *newData = RL_MALLOC(dataSize); unsigned char *newData = RL_MALLOC(dataSize);
int it = dataSize / sizeof(unsigned char); int it = dataSize / sizeof(unsigned char);
for (int i = 0; i < it; i++){ for (int i = 0; i < it; i++){
newData[i] = data[i]; newData[i] = data[i];
} }
TRACELOG(LOG_WARNING, "-------: %d / %d = %d", dataSize, sizeof(unsigned char), it); TRACELOG(LOG_WARNING, "-------: %d / %d = %d", dataSize, sizeof(unsigned char), it);
// Memory loaded version for jar_mod_load_file() // Memory loaded version for jar_mod_load_file()
if (dataSize && dataSize < 32*1024*1024) if (dataSize && dataSize < 32*1024*1024)
{ {
ctxMod->modfilesize = dataSize; ctxMod->modfilesize = dataSize;
ctxMod->modfile = newData; ctxMod->modfile = newData;
if(jar_mod_load(ctxMod, (void*)ctxMod->modfile, dataSize)) result = dataSize; if(jar_mod_load(ctxMod, (void*)ctxMod->modfile, dataSize)) result = dataSize;
} }
if (result > 0) if (result > 0)
{ {
music.ctxType = MUSIC_MODULE_MOD; music.ctxType = MUSIC_MODULE_MOD;
@ -1361,11 +1361,11 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
musicLoaded = true; musicLoaded = true;
music.ctxData = ctxMod; music.ctxData = ctxMod;
musicLoaded = true; musicLoaded = true;
} }
} }
#endif #endif
else TRACELOG(LOG_WARNING, "STREAM: [%s] Fileformat not supported", fileType); else TRACELOG(LOG_WARNING, "STREAM: [%s] Fileformat not supported", fileType);
if (!musicLoaded) if (!musicLoaded)
{ {