mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Rename enum LogType names...
...to avoid possible conflicting symbols
This commit is contained in:
145
src/audio.c
145
src/audio.c
@ -170,7 +170,7 @@ typedef struct MusicData {
|
||||
} MusicData;
|
||||
|
||||
#if defined(AUDIO_STANDALONE)
|
||||
typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
|
||||
typedef enum { LOG_INFO = 0, LOG_ERROR, LOG_WARNING, LOG_DEBUG, LOG_OTHER } TraceLogType;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -193,7 +193,7 @@ static Wave LoadFLAC(const char *fileName); // Load FLAC file
|
||||
|
||||
#if defined(AUDIO_STANDALONE)
|
||||
bool IsFileExtension(const char *fileName, const char *ext); // Check file extension
|
||||
void TraceLog(int msgType, const char *text, ...); // Outputs trace log message (INFO, ERROR, WARNING)
|
||||
void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -206,7 +206,7 @@ void InitAudioDevice(void)
|
||||
// Open and initialize a device with default settings
|
||||
ALCdevice *device = alcOpenDevice(NULL);
|
||||
|
||||
if (!device) TraceLog(ERROR, "Audio device could not be opened");
|
||||
if (!device) TraceLog(LOG_ERROR, "Audio device could not be opened");
|
||||
else
|
||||
{
|
||||
ALCcontext *context = alcCreateContext(device, NULL);
|
||||
@ -217,11 +217,11 @@ void InitAudioDevice(void)
|
||||
|
||||
alcCloseDevice(device);
|
||||
|
||||
TraceLog(ERROR, "Could not initialize audio context");
|
||||
TraceLog(LOG_ERROR, "Could not initialize audio context");
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLog(INFO, "Audio device and context initialized successfully: %s", alcGetString(device, ALC_DEVICE_SPECIFIER));
|
||||
TraceLog(LOG_INFO, "Audio device and context initialized successfully: %s", alcGetString(device, ALC_DEVICE_SPECIFIER));
|
||||
|
||||
// Listener definition (just for 2D)
|
||||
alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
@ -239,7 +239,7 @@ void CloseAudioDevice(void)
|
||||
ALCdevice *device;
|
||||
ALCcontext *context = alcGetCurrentContext();
|
||||
|
||||
if (context == NULL) TraceLog(WARNING, "Could not get current audio context for closing");
|
||||
if (context == NULL) TraceLog(LOG_WARNING, "Could not get current audio context for closing");
|
||||
|
||||
device = alcGetContextsDevice(context);
|
||||
|
||||
@ -247,7 +247,7 @@ void CloseAudioDevice(void)
|
||||
alcDestroyContext(context);
|
||||
alcCloseDevice(device);
|
||||
|
||||
TraceLog(INFO, "Audio device closed successfully");
|
||||
TraceLog(LOG_INFO, "Audio device closed successfully");
|
||||
}
|
||||
|
||||
// Check if device has been initialized successfully
|
||||
@ -298,12 +298,12 @@ Wave LoadWave(const char *fileName)
|
||||
// NOTE: Parameters for RRES_TYPE_WAVE are: sampleCount, sampleRate, sampleSize, channels
|
||||
|
||||
if (rres[0].type == RRES_TYPE_WAVE) wave = LoadWaveEx(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3, rres[0].param4);
|
||||
else TraceLog(WARNING, "[%s] Resource file does not contain wave data", fileName);
|
||||
else TraceLog(LOG_WARNING, "[%s] Resource file does not contain wave data", fileName);
|
||||
|
||||
UnloadResource(rres);
|
||||
}
|
||||
#endif
|
||||
else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
|
||||
else TraceLog(LOG_WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
|
||||
|
||||
return wave;
|
||||
}
|
||||
@ -358,7 +358,7 @@ Sound LoadSoundFromWave(Wave wave)
|
||||
case 8: format = AL_FORMAT_MONO8; break;
|
||||
case 16: format = AL_FORMAT_MONO16; break;
|
||||
case 32: format = AL_FORMAT_MONO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
|
||||
default: TraceLog(WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
|
||||
default: TraceLog(LOG_WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
|
||||
}
|
||||
}
|
||||
else if (wave.channels == 2)
|
||||
@ -368,10 +368,10 @@ Sound LoadSoundFromWave(Wave wave)
|
||||
case 8: format = AL_FORMAT_STEREO8; break;
|
||||
case 16: format = AL_FORMAT_STEREO16; break;
|
||||
case 32: format = AL_FORMAT_STEREO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
|
||||
default: TraceLog(WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
|
||||
default: TraceLog(LOG_WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
|
||||
}
|
||||
}
|
||||
else TraceLog(WARNING, "Wave number of channels not supported: %i", wave.channels);
|
||||
else TraceLog(LOG_WARNING, "Wave number of channels not supported: %i", wave.channels);
|
||||
|
||||
// Create an audio source
|
||||
ALuint source;
|
||||
@ -396,7 +396,7 @@ Sound LoadSoundFromWave(Wave wave)
|
||||
// Attach sound buffer to source
|
||||
alSourcei(source, AL_BUFFER, buffer);
|
||||
|
||||
TraceLog(INFO, "[SND ID %i][BUFR ID %i] Sound data loaded successfully (%i Hz, %i bit, %s)", source, buffer, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
TraceLog(LOG_INFO, "[SND ID %i][BUFR ID %i] Sound data loaded successfully (%i Hz, %i bit, %s)", source, buffer, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
|
||||
sound.source = source;
|
||||
sound.buffer = buffer;
|
||||
@ -411,7 +411,7 @@ void UnloadWave(Wave wave)
|
||||
{
|
||||
if (wave.data != NULL) free(wave.data);
|
||||
|
||||
TraceLog(INFO, "Unloaded wave data from RAM");
|
||||
TraceLog(LOG_INFO, "Unloaded wave data from RAM");
|
||||
}
|
||||
|
||||
// Unload sound
|
||||
@ -422,7 +422,7 @@ void UnloadSound(Sound sound)
|
||||
alDeleteSources(1, &sound.source);
|
||||
alDeleteBuffers(1, &sound.buffer);
|
||||
|
||||
TraceLog(INFO, "[SND ID %i][BUFR ID %i] Unloaded sound data from RAM", sound.source, sound.buffer);
|
||||
TraceLog(LOG_INFO, "[SND ID %i][BUFR ID %i] Unloaded sound data from RAM", sound.source, sound.buffer);
|
||||
}
|
||||
|
||||
// Update sound buffer with new data
|
||||
@ -434,9 +434,9 @@ void UpdateSound(Sound sound, const void *data, int samplesCount)
|
||||
alGetBufferi(sound.buffer, AL_BITS, &sampleSize); // It could also be retrieved from sound.format
|
||||
alGetBufferi(sound.buffer, AL_CHANNELS, &channels); // It could also be retrieved from sound.format
|
||||
|
||||
TraceLog(DEBUG, "UpdateSound() : AL_FREQUENCY: %i", sampleRate);
|
||||
TraceLog(DEBUG, "UpdateSound() : AL_BITS: %i", sampleSize);
|
||||
TraceLog(DEBUG, "UpdateSound() : AL_CHANNELS: %i", channels);
|
||||
TraceLog(LOG_DEBUG, "UpdateSound() : AL_FREQUENCY: %i", sampleRate);
|
||||
TraceLog(LOG_DEBUG, "UpdateSound() : AL_BITS: %i", sampleSize);
|
||||
TraceLog(LOG_DEBUG, "UpdateSound() : AL_CHANNELS: %i", channels);
|
||||
|
||||
unsigned int dataSize = samplesCount*channels*sampleSize/8; // Size of data in bytes
|
||||
|
||||
@ -457,7 +457,7 @@ void PlaySound(Sound sound)
|
||||
{
|
||||
alSourcePlay(sound.source); // Play the sound
|
||||
|
||||
//TraceLog(INFO, "Playing sound");
|
||||
//TraceLog(LOG_INFO, "Playing sound");
|
||||
|
||||
// Find the current position of the sound being played
|
||||
// NOTE: Only work when the entire file is in a single buffer
|
||||
@ -639,7 +639,7 @@ void WaveCrop(Wave *wave, int initSample, int finalSample)
|
||||
free(wave->data);
|
||||
wave->data = data;
|
||||
}
|
||||
else TraceLog(WARNING, "Wave crop range out of bounds");
|
||||
else TraceLog(LOG_WARNING, "Wave crop range out of bounds");
|
||||
}
|
||||
|
||||
// Get samples data from wave as a floats array
|
||||
@ -675,7 +675,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
// Open ogg audio stream
|
||||
music->ctxOgg = stb_vorbis_open_filename(fileName, NULL, NULL);
|
||||
|
||||
if (music->ctxOgg == NULL) TraceLog(WARNING, "[%s] OGG audio file could not be opened", fileName);
|
||||
if (music->ctxOgg == NULL) TraceLog(LOG_WARNING, "[%s] OGG audio file could not be opened", fileName);
|
||||
else
|
||||
{
|
||||
stb_vorbis_info info = stb_vorbis_get_info(music->ctxOgg); // Get Ogg file info
|
||||
@ -687,10 +687,10 @@ Music LoadMusicStream(const char *fileName)
|
||||
music->ctxType = MUSIC_AUDIO_OGG;
|
||||
music->loopCount = -1; // Infinite loop by default
|
||||
|
||||
TraceLog(DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
|
||||
TraceLog(DEBUG, "[%s] OGG sample rate: %i", fileName, info.sample_rate);
|
||||
TraceLog(DEBUG, "[%s] OGG channels: %i", fileName, info.channels);
|
||||
TraceLog(DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
|
||||
TraceLog(LOG_DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
|
||||
TraceLog(LOG_DEBUG, "[%s] OGG sample rate: %i", fileName, info.sample_rate);
|
||||
TraceLog(LOG_DEBUG, "[%s] OGG channels: %i", fileName, info.channels);
|
||||
TraceLog(LOG_DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
|
||||
}
|
||||
}
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
@ -698,7 +698,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
{
|
||||
music->ctxFlac = drflac_open_file(fileName);
|
||||
|
||||
if (music->ctxFlac == NULL) TraceLog(WARNING, "[%s] FLAC audio file could not be opened", fileName);
|
||||
if (music->ctxFlac == NULL) TraceLog(LOG_WARNING, "[%s] FLAC audio file could not be opened", fileName);
|
||||
else
|
||||
{
|
||||
music->stream = InitAudioStream(music->ctxFlac->sampleRate, music->ctxFlac->bitsPerSample, music->ctxFlac->channels);
|
||||
@ -707,10 +707,10 @@ Music LoadMusicStream(const char *fileName)
|
||||
music->ctxType = MUSIC_AUDIO_FLAC;
|
||||
music->loopCount = -1; // Infinite loop by default
|
||||
|
||||
TraceLog(DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
|
||||
TraceLog(DEBUG, "[%s] FLAC sample rate: %i", fileName, music->ctxFlac->sampleRate);
|
||||
TraceLog(DEBUG, "[%s] FLAC bits per sample: %i", fileName, music->ctxFlac->bitsPerSample);
|
||||
TraceLog(DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels);
|
||||
TraceLog(LOG_DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
|
||||
TraceLog(LOG_DEBUG, "[%s] FLAC sample rate: %i", fileName, music->ctxFlac->sampleRate);
|
||||
TraceLog(LOG_DEBUG, "[%s] FLAC bits per sample: %i", fileName, music->ctxFlac->bitsPerSample);
|
||||
TraceLog(LOG_DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -730,10 +730,10 @@ Music LoadMusicStream(const char *fileName)
|
||||
music->ctxType = MUSIC_MODULE_XM;
|
||||
music->loopCount = -1; // Infinite loop by default
|
||||
|
||||
TraceLog(DEBUG, "[%s] XM number of samples: %i", fileName, music->totalSamples);
|
||||
TraceLog(DEBUG, "[%s] XM track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
|
||||
TraceLog(LOG_DEBUG, "[%s] XM number of samples: %i", fileName, music->totalSamples);
|
||||
TraceLog(LOG_DEBUG, "[%s] XM track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
|
||||
}
|
||||
else TraceLog(WARNING, "[%s] XM file could not be opened", fileName);
|
||||
else TraceLog(LOG_WARNING, "[%s] XM file could not be opened", fileName);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
@ -749,13 +749,13 @@ Music LoadMusicStream(const char *fileName)
|
||||
music->ctxType = MUSIC_MODULE_MOD;
|
||||
music->loopCount = -1; // Infinite loop by default
|
||||
|
||||
TraceLog(DEBUG, "[%s] MOD number of samples: %i", fileName, music->samplesLeft);
|
||||
TraceLog(DEBUG, "[%s] MOD track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
|
||||
TraceLog(LOG_DEBUG, "[%s] MOD number of samples: %i", fileName, music->samplesLeft);
|
||||
TraceLog(LOG_DEBUG, "[%s] MOD track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
|
||||
}
|
||||
else TraceLog(WARNING, "[%s] MOD file could not be opened", fileName);
|
||||
else TraceLog(LOG_WARNING, "[%s] MOD file could not be opened", fileName);
|
||||
}
|
||||
#endif
|
||||
else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
|
||||
else TraceLog(LOG_WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
|
||||
|
||||
return music;
|
||||
}
|
||||
@ -799,7 +799,7 @@ void ResumeMusicStream(Music music)
|
||||
|
||||
if (state == AL_PAUSED)
|
||||
{
|
||||
TraceLog(INFO, "[AUD ID %i] Resume music stream playing", music->stream.source);
|
||||
TraceLog(LOG_INFO, "[AUD ID %i] Resume music stream playing", music->stream.source);
|
||||
alSourcePlay(music->stream.source);
|
||||
}
|
||||
}
|
||||
@ -992,7 +992,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||
if ((channels > 0) && (channels < 3)) stream.channels = channels;
|
||||
else
|
||||
{
|
||||
TraceLog(WARNING, "Init audio stream: Number of channels not supported: %i", channels);
|
||||
TraceLog(LOG_WARNING, "Init audio stream: Number of channels not supported: %i", channels);
|
||||
stream.channels = 1; // Fallback to mono channel
|
||||
}
|
||||
|
||||
@ -1004,7 +1004,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||
case 8: stream.format = AL_FORMAT_MONO8; break;
|
||||
case 16: stream.format = AL_FORMAT_MONO16; break;
|
||||
case 32: stream.format = AL_FORMAT_MONO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
|
||||
default: TraceLog(WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
|
||||
default: TraceLog(LOG_WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
|
||||
}
|
||||
}
|
||||
else if (stream.channels == 2)
|
||||
@ -1014,7 +1014,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||
case 8: stream.format = AL_FORMAT_STEREO8; break;
|
||||
case 16: stream.format = AL_FORMAT_STEREO16; break;
|
||||
case 32: stream.format = AL_FORMAT_STEREO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
|
||||
default: TraceLog(WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
|
||||
default: TraceLog(LOG_WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1041,7 +1041,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||
|
||||
alSourceQueueBuffers(stream.source, MAX_STREAM_BUFFERS, stream.buffers);
|
||||
|
||||
TraceLog(INFO, "[AUD ID %i] Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.source, stream.sampleRate, stream.sampleSize, (stream.channels == 1) ? "Mono" : "Stereo");
|
||||
TraceLog(LOG_INFO, "[AUD ID %i] Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.source, stream.sampleRate, stream.sampleSize, (stream.channels == 1) ? "Mono" : "Stereo");
|
||||
|
||||
return stream;
|
||||
}
|
||||
@ -1068,7 +1068,7 @@ void CloseAudioStream(AudioStream stream)
|
||||
alDeleteSources(1, &stream.source);
|
||||
alDeleteBuffers(MAX_STREAM_BUFFERS, stream.buffers);
|
||||
|
||||
TraceLog(INFO, "[AUD ID %i] Unloaded audio stream data", stream.source);
|
||||
TraceLog(LOG_INFO, "[AUD ID %i] Unloaded audio stream data", stream.source);
|
||||
}
|
||||
|
||||
// Update audio stream buffers with data
|
||||
@ -1085,7 +1085,7 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
|
||||
alBufferData(buffer, stream.format, data, samplesCount*stream.sampleSize/8*stream.channels, stream.sampleRate);
|
||||
alSourceQueueBuffers(stream.source, 1, &buffer);
|
||||
}
|
||||
else TraceLog(WARNING, "[AUD ID %i] Audio buffer not available for unqueuing", stream.source);
|
||||
else TraceLog(LOG_WARNING, "[AUD ID %i] Audio buffer not available for unqueuing", stream.source);
|
||||
}
|
||||
|
||||
// Check if any audio stream buffers requires refill
|
||||
@ -1168,7 +1168,7 @@ static Wave LoadWAV(const char *fileName)
|
||||
|
||||
if (wavFile == NULL)
|
||||
{
|
||||
TraceLog(WARNING, "[%s] WAV file could not be opened", fileName);
|
||||
TraceLog(LOG_WARNING, "[%s] WAV file could not be opened", fileName);
|
||||
wave.data = NULL;
|
||||
}
|
||||
else
|
||||
@ -1180,7 +1180,7 @@ static Wave LoadWAV(const char *fileName)
|
||||
if (strncmp(wavRiffHeader.chunkID, "RIFF", 4) ||
|
||||
strncmp(wavRiffHeader.format, "WAVE", 4))
|
||||
{
|
||||
TraceLog(WARNING, "[%s] Invalid RIFF or WAVE Header", fileName);
|
||||
TraceLog(LOG_WARNING, "[%s] Invalid RIFF or WAVE Header", fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1191,7 +1191,7 @@ static Wave LoadWAV(const char *fileName)
|
||||
if ((wavFormat.subChunkID[0] != 'f') || (wavFormat.subChunkID[1] != 'm') ||
|
||||
(wavFormat.subChunkID[2] != 't') || (wavFormat.subChunkID[3] != ' '))
|
||||
{
|
||||
TraceLog(WARNING, "[%s] Invalid Wave format", fileName);
|
||||
TraceLog(LOG_WARNING, "[%s] Invalid Wave format", fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1205,7 +1205,7 @@ static Wave LoadWAV(const char *fileName)
|
||||
if ((wavData.subChunkID[0] != 'd') || (wavData.subChunkID[1] != 'a') ||
|
||||
(wavData.subChunkID[2] != 't') || (wavData.subChunkID[3] != 'a'))
|
||||
{
|
||||
TraceLog(WARNING, "[%s] Invalid data header", fileName);
|
||||
TraceLog(LOG_WARNING, "[%s] Invalid data header", fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1223,7 +1223,7 @@ static Wave LoadWAV(const char *fileName)
|
||||
// NOTE: Only support 8 bit, 16 bit and 32 bit sample sizes
|
||||
if ((wave.sampleSize != 8) && (wave.sampleSize != 16) && (wave.sampleSize != 32))
|
||||
{
|
||||
TraceLog(WARNING, "[%s] WAV sample size (%ibit) not supported, converted to 16bit", fileName, wave.sampleSize);
|
||||
TraceLog(LOG_WARNING, "[%s] WAV sample size (%ibit) not supported, converted to 16bit", fileName, wave.sampleSize);
|
||||
WaveFormat(&wave, wave.sampleRate, 16, wave.channels);
|
||||
}
|
||||
|
||||
@ -1231,13 +1231,13 @@ static Wave LoadWAV(const char *fileName)
|
||||
if (wave.channels > 2)
|
||||
{
|
||||
WaveFormat(&wave, wave.sampleRate, wave.sampleSize, 2);
|
||||
TraceLog(WARNING, "[%s] WAV channels number (%i) not supported, converted to 2 channels", fileName, wave.channels);
|
||||
TraceLog(LOG_WARNING, "[%s] WAV channels number (%i) not supported, converted to 2 channels", fileName, wave.channels);
|
||||
}
|
||||
|
||||
// NOTE: subChunkSize comes in bytes, we need to translate it to number of samples
|
||||
wave.sampleCount = (wavData.subChunkSize/(wave.sampleSize/8))/wave.channels;
|
||||
|
||||
TraceLog(INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
TraceLog(LOG_INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1258,7 +1258,7 @@ static Wave LoadOGG(const char *fileName)
|
||||
|
||||
stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL);
|
||||
|
||||
if (oggFile == NULL) TraceLog(WARNING, "[%s] OGG file could not be opened", fileName);
|
||||
if (oggFile == NULL) TraceLog(LOG_WARNING, "[%s] OGG file could not be opened", fileName);
|
||||
else
|
||||
{
|
||||
stb_vorbis_info info = stb_vorbis_get_info(oggFile);
|
||||
@ -1269,16 +1269,16 @@ static Wave LoadOGG(const char *fileName)
|
||||
wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); // Independent by channel
|
||||
|
||||
float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile);
|
||||
if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
|
||||
if (totalSeconds > 10) TraceLog(LOG_WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
|
||||
|
||||
wave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short));
|
||||
|
||||
// NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!)
|
||||
int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, (short *)wave.data, wave.sampleCount*wave.channels);
|
||||
|
||||
TraceLog(DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg);
|
||||
TraceLog(LOG_DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg);
|
||||
|
||||
TraceLog(INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
TraceLog(LOG_INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
|
||||
stb_vorbis_close(oggFile);
|
||||
}
|
||||
@ -1302,10 +1302,10 @@ static Wave LoadFLAC(const char *fileName)
|
||||
wave.sampleSize = 16;
|
||||
|
||||
// NOTE: Only support up to 2 channels (mono, stereo)
|
||||
if (wave.channels > 2) TraceLog(WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels);
|
||||
if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels);
|
||||
|
||||
if (wave.data == NULL) TraceLog(WARNING, "[%s] FLAC data could not be loaded", fileName);
|
||||
else TraceLog(INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] FLAC data could not be loaded", fileName);
|
||||
else TraceLog(LOG_INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
|
||||
|
||||
return wave;
|
||||
}
|
||||
@ -1327,35 +1327,26 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Outputs a trace log message (INFO, ERROR, WARNING)
|
||||
// NOTE: If a file has been init, output log is written there
|
||||
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
|
||||
void TraceLog(int msgType, const char *text, ...)
|
||||
{
|
||||
va_list args;
|
||||
int traceDebugMsgs = 0;
|
||||
|
||||
#if defined(DO_NOT_TRACE_DEBUG_MSGS)
|
||||
traceDebugMsgs = 0;
|
||||
#endif
|
||||
va_start(args, text);
|
||||
|
||||
switch (msgType)
|
||||
{
|
||||
case INFO: fprintf(stdout, "INFO: "); break;
|
||||
case ERROR: fprintf(stdout, "ERROR: "); break;
|
||||
case WARNING: fprintf(stdout, "WARNING: "); break;
|
||||
case DEBUG: if (traceDebugMsgs) fprintf(stdout, "DEBUG: "); break;
|
||||
case LOG_INFO: fprintf(stdout, "INFO: "); break;
|
||||
case LOG_ERROR: fprintf(stdout, "ERROR: "); break;
|
||||
case LOG_WARNING: fprintf(stdout, "WARNING: "); break;
|
||||
case LOG_DEBUG: fprintf(stdout, "DEBUG: "); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if ((msgType != DEBUG) || ((msgType == DEBUG) && (traceDebugMsgs)))
|
||||
{
|
||||
va_start(args, text);
|
||||
vfprintf(stdout, text, args);
|
||||
va_end(args);
|
||||
vfprintf(stdout, text, args);
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
if (msgType == ERROR) exit(1); // If ERROR message, exit program
|
||||
if (msgType == LOG_ERROR) exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user