Review QOA sound loading -WIP-

This commit is contained in:
Ray 2023-02-05 16:28:04 +01:00
parent ff70a04bf5
commit c91190fc6e

View file

@ -829,18 +829,26 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
{
qoa_desc qoa = { 0 };
// NOTE: Returned sample data is always 16 bit?
wave.data = qoa_decode(fileData, dataSize, &qoa);
wave.sampleSize = 16;
unsigned int result = qoa_decode_header(fileData, dataSize, &qoa);
if (wave.data != NULL)
if (result > 0)
{
wave.channels = qoa.channels;
wave.sampleRate = qoa.samplerate;
// Calculate the total audio frame count
wave.frameCount = qoa.samples;
// NOTE: Returned sample data is always 16 bit
wave.data = qoa_decode(fileData, dataSize, &qoa);
wave.sampleSize = 16;
if (wave.data != NULL)
{
wave.channels = qoa.channels;
wave.sampleRate = qoa.samplerate;
}
else TRACELOG(LOG_WARNING, "WAVE: Failed to load QOA data");
}
else TRACELOG(LOG_WARNING, "WAVE: Failed to load QOA data");
}
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
@ -1380,6 +1388,7 @@ Music LoadMusicStream(const char *fileName)
qoa_desc *ctxQoa = RL_CALLOC(1, sizeof(qoa_desc));
// TODO: QOA stream support: Init context from file
int result = 0;
music.ctxType = MUSIC_AUDIO_QOA;
music.ctxData = ctxQoa;
@ -1578,11 +1587,12 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
qoa_desc *ctxQoa = RL_CALLOC(1, sizeof(qoa_desc));
// TODO: Init QOA context data
int result = 0;
music.ctxType = MUSIC_AUDIO_QOA;
music.ctxData = ctxQoa;
if (success)
if (result > 0)
{
music.stream = LoadAudioStream(ctxQoa->samplerate, 16, ctxQoa->channels);