Fix console rendering old strings, refactor audio

Removed duplication of audio buffering code in audio update and streaming
vorbis.
This commit is contained in:
Doyle Thai 2016-07-27 01:40:22 +10:00
parent 84a0f755ea
commit 9c3df0c488
2 changed files with 10 additions and 19 deletions

View File

@ -11,7 +11,6 @@
#define AL_CHECK_ERROR() alCheckError_(__FILE__, __LINE__);
void alCheckError_(const char *file, int line)
{
ALenum errorCode;
while ((errorCode = alGetError()) != AL_NO_ERROR)
{
@ -83,29 +82,16 @@ void audio_streamVorbis(AudioRenderer *audioRenderer, AudioVorbis *vorbis)
audioRenderer->audio = vorbis;
AudioVorbis *audio = audioRenderer->audio;
/* Pre-load vorbis data into audio chunks */
for (i32 i = 0; i < ARRAY_COUNT(audioRenderer->bufferId); i++)
{
i16 audioChunk[AUDIO_CHUNK_SIZE_] = {0};
stb_vorbis_get_samples_short_interleaved(
audio->file, audio->info.channels, audioChunk, AUDIO_CHUNK_SIZE_);
alBufferData(audioRenderer->bufferId[i], audioRenderer->format,
audioChunk, AUDIO_CHUNK_SIZE_ * sizeof(i16),
audio->info.sample_rate);
}
/* Queue and play buffers */
alSourceQueueBuffers(audioRenderer->sourceId[0],
ARRAY_COUNT(audioRenderer->bufferId),
audioRenderer->bufferId);
alSourcePlay(audioRenderer->sourceId[0]);
}
void audio_updateAndPlay(AudioRenderer *audioRenderer)
{
AudioVorbis *audio = audioRenderer->audio;
if (!audio)
{
DEBUG_LOG("audio_updateAndPlay() early exit: No audio stream connected");
return;
}
ALint audioState;
alGetSourcei(audioRenderer->sourceId[0], AL_SOURCE_STATE, &audioState);

View File

@ -32,8 +32,13 @@ void debug_init(MemoryArena *arena, v2 windowSize, Font font)
void debug_consoleLog(char *string, char *file, int lineNum)
{
i32 maxConsoleStrLen = ARRAY_COUNT(GLOBAL_debug.console[0]);
/* Completely clear out current console line */
for (i32 i = 0; i < maxConsoleStrLen; i++)
GLOBAL_debug.console[GLOBAL_debug.consoleIndex][i] = 0;
i32 strIndex = 0;
i32 fileStrLen = common_strlen(file);
for (i32 count = 0; strIndex < maxConsoleStrLen; strIndex++, count++)