Formating tweaks
This commit is contained in:
parent
108f7f6fee
commit
e6e48675cc
1 changed files with 19 additions and 17 deletions
30
src/raudio.c
30
src/raudio.c
|
@ -206,7 +206,7 @@ struct rAudioBuffer {
|
||||||
int usage; // Audio buffer usage mode: STATIC or STREAM
|
int usage; // Audio buffer usage mode: STATIC or STREAM
|
||||||
|
|
||||||
bool isSubBufferProcessed[2];
|
bool isSubBufferProcessed[2];
|
||||||
unsigned int frameCursorPos;
|
unsigned int frameCursorPos; // Samples processed?
|
||||||
unsigned int bufferSizeInFrames;
|
unsigned int bufferSizeInFrames;
|
||||||
|
|
||||||
rAudioBuffer *next;
|
rAudioBuffer *next;
|
||||||
|
@ -877,7 +877,7 @@ void UpdateSound(Sound sound, const void *data, int samplesCount)
|
||||||
|
|
||||||
StopAudioBuffer(audioBuffer);
|
StopAudioBuffer(audioBuffer);
|
||||||
|
|
||||||
// TODO: May want to lock/unlock this since this data buffer is read at mixing time.
|
// TODO: May want to lock/unlock this since this data buffer is read at mixing time
|
||||||
memcpy(audioBuffer->buffer, data, samplesCount*audioBuffer->dsp.formatConverterIn.config.channels*ma_get_bytes_per_sample(audioBuffer->dsp.formatConverterIn.config.formatIn));
|
memcpy(audioBuffer->buffer, data, samplesCount*audioBuffer->dsp.formatConverterIn.config.channels*ma_get_bytes_per_sample(audioBuffer->dsp.formatConverterIn.config.formatIn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,10 +1188,10 @@ Music LoadMusicStream(const char *fileName)
|
||||||
music.loopCount = 0; // Infinite loop by default
|
music.loopCount = 0; // Infinite loop by default
|
||||||
musicLoaded = true;
|
musicLoaded = true;
|
||||||
|
|
||||||
TraceLog(LOG_DEBUG, "[%s] OGG total samples: %i", fileName, music.sampleCount);
|
TraceLog(LOG_INFO, "[%s] OGG total samples: %i", fileName, music.sampleCount);
|
||||||
TraceLog(LOG_DEBUG, "[%s] OGG sample rate: %i", fileName, info.sample_rate);
|
TraceLog(LOG_INFO, "[%s] OGG sample rate: %i", fileName, info.sample_rate);
|
||||||
TraceLog(LOG_DEBUG, "[%s] OGG channels: %i", fileName, info.channels);
|
TraceLog(LOG_INFO, "[%s] OGG channels: %i", fileName, info.channels);
|
||||||
TraceLog(LOG_DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
|
TraceLog(LOG_INFO, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1289,7 +1289,7 @@ Music LoadMusicStream(const char *fileName)
|
||||||
music.loopCount = 0; // Infinite loop by default
|
music.loopCount = 0; // Infinite loop by default
|
||||||
musicLoaded = true;
|
musicLoaded = true;
|
||||||
|
|
||||||
TraceLog(LOG_INFO, "[%s] MOD number of samples: %i", fileName, music.sampleLeft);
|
TraceLog(LOG_INFO, "[%s] MOD number of samples: %i", fileName, music.sampleCount);
|
||||||
TraceLog(LOG_INFO, "[%s] MOD track length: %11.6f sec", fileName, (float)music.sampleCount/48000.0f);
|
TraceLog(LOG_INFO, "[%s] MOD track length: %11.6f sec", fileName, (float)music.sampleCount/48000.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1354,10 +1354,10 @@ void PlayMusicStream(Music music)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For music streams, we need to make sure we maintain the frame cursor position. This is hack for this section of code in UpdateMusicStream()
|
// For music streams, we need to make sure we maintain the frame cursor position
|
||||||
// // NOTE: In case window is minimized, music stream is stopped,
|
// This is a hack for this section of code in UpdateMusicStream()
|
||||||
// // just make sure to play again on window restore
|
// NOTE: In case window is minimized, music stream is stopped, just make sure to
|
||||||
// if (IsMusicPlaying(music)) PlayMusicStream(music);
|
// play again on window restore: if (IsMusicPlaying(music)) PlayMusicStream(music);
|
||||||
ma_uint32 frameCursorPos = audioBuffer->frameCursorPos;
|
ma_uint32 frameCursorPos = audioBuffer->frameCursorPos;
|
||||||
|
|
||||||
PlayAudioStream(music.stream); // <-- This resets the cursor position.
|
PlayAudioStream(music.stream); // <-- This resets the cursor position.
|
||||||
|
@ -1528,7 +1528,7 @@ void SetMusicPitch(Music music, float pitch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set music loop count (loop repeats)
|
// Set music loop count (loop repeats)
|
||||||
// NOTE: If set to -1, means infinite loop
|
// NOTE: If set to 0, means infinite loop
|
||||||
void SetMusicLoopCount(Music music, int count)
|
void SetMusicLoopCount(Music music, int count)
|
||||||
{
|
{
|
||||||
music.loopCount = count;
|
music.loopCount = count;
|
||||||
|
@ -1622,7 +1622,8 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
|
||||||
|
|
||||||
if (audioBuffer->isSubBufferProcessed[0] && audioBuffer->isSubBufferProcessed[1])
|
if (audioBuffer->isSubBufferProcessed[0] && audioBuffer->isSubBufferProcessed[1])
|
||||||
{
|
{
|
||||||
// Both buffers are available for updating. Update the first one and make sure the cursor is moved back to the front.
|
// Both buffers are available for updating.
|
||||||
|
// Update the first one and make sure the cursor is moved back to the front.
|
||||||
subBufferToUpdate = 0;
|
subBufferToUpdate = 0;
|
||||||
audioBuffer->frameCursorPos = 0;
|
audioBuffer->frameCursorPos = 0;
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1636,8 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
|
||||||
ma_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
|
ma_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
|
||||||
unsigned char *subBuffer = audioBuffer->buffer + ((subBufferSizeInFrames*stream.channels*(stream.sampleSize/8))*subBufferToUpdate);
|
unsigned char *subBuffer = audioBuffer->buffer + ((subBufferSizeInFrames*stream.channels*(stream.sampleSize/8))*subBufferToUpdate);
|
||||||
|
|
||||||
// Does this API expect a whole buffer to be updated in one go? Assuming so, but if not will need to change this logic.
|
// Does this API expect a whole buffer to be updated in one go?
|
||||||
|
// Assuming so, but if not will need to change this logic.
|
||||||
if (subBufferSizeInFrames >= (ma_uint32)samplesCount/stream.channels)
|
if (subBufferSizeInFrames >= (ma_uint32)samplesCount/stream.channels)
|
||||||
{
|
{
|
||||||
ma_uint32 framesToWrite = subBufferSizeInFrames;
|
ma_uint32 framesToWrite = subBufferSizeInFrames;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue