Rename variable

This commit is contained in:
Milan Nikolic 2017-02-10 11:43:11 +01:00
parent 2f90318d30
commit aa4f9a657a
4 changed files with 25 additions and 24 deletions

View file

@ -379,7 +379,7 @@ void UnloadSound(Sound sound)
// Update sound buffer with new data // Update sound buffer with new data
// NOTE: data must match sound.format // NOTE: data must match sound.format
void UpdateSound(Sound sound, const void *data, int numSamples) void UpdateSound(Sound sound, const void *data, int samplesCount)
{ {
ALint sampleRate, sampleSize, channels; ALint sampleRate, sampleSize, channels;
alGetBufferi(sound.buffer, AL_FREQUENCY, &sampleRate); alGetBufferi(sound.buffer, AL_FREQUENCY, &sampleRate);
@ -390,7 +390,7 @@ void UpdateSound(Sound sound, const void *data, int numSamples)
TraceLog(DEBUG, "UpdateSound() : AL_BITS: %i", sampleSize); TraceLog(DEBUG, "UpdateSound() : AL_BITS: %i", sampleSize);
TraceLog(DEBUG, "UpdateSound() : AL_CHANNELS: %i", channels); TraceLog(DEBUG, "UpdateSound() : AL_CHANNELS: %i", channels);
unsigned int dataSize = numSamples*channels*sampleSize/8; // Size of data in bytes unsigned int dataSize = samplesCount*channels*sampleSize/8; // Size of data in bytes
alSourceStop(sound.source); // Stop sound alSourceStop(sound.source); // Stop sound
alSourcei(sound.source, AL_BUFFER, 0); // Unbind buffer from sound to update alSourcei(sound.source, AL_BUFFER, 0); // Unbind buffer from sound to update
@ -757,6 +757,7 @@ void StopMusicStream(Music music)
} }
// Update (re-fill) music buffers if data already processed // Update (re-fill) music buffers if data already processed
// TODO: Make sure buffers are ready for update... check music state
void UpdateMusicStream(Music music) void UpdateMusicStream(Music music)
{ {
ALenum state; ALenum state;
@ -773,13 +774,13 @@ void UpdateMusicStream(Music music)
void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.channels*music->stream.sampleSize/8, 1); void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.channels*music->stream.sampleSize/8, 1);
int numBuffersToProcess = processed; int numBuffersToProcess = processed;
int numSamples = 0; // Total size of data steamed in L+R samples for xm floats, int samplesCount = 0; // Total size of data steamed in L+R samples for xm floats,
// individual L or R for ogg shorts //individual L or R for ogg shorts
for (int i = 0; i < numBuffersToProcess; i++) for (int i = 0; i < numBuffersToProcess; i++)
{ {
if (music->samplesLeft >= AUDIO_BUFFER_SIZE) numSamples = AUDIO_BUFFER_SIZE; if (music->samplesLeft >= AUDIO_BUFFER_SIZE) samplesCount = AUDIO_BUFFER_SIZE;
else numSamples = music->samplesLeft; else samplesCount = music->samplesLeft;
// TODO: Really don't like ctxType thingy... // TODO: Really don't like ctxType thingy...
switch (music->ctxType) switch (music->ctxType)
@ -787,22 +788,22 @@ void UpdateMusicStream(Music music)
case MUSIC_AUDIO_OGG: case MUSIC_AUDIO_OGG:
{ {
// NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!) // NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!)
int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, numSamples*music->stream.channels); int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, samplesCount*music->stream.channels);
} break; } break;
case MUSIC_AUDIO_FLAC: case MUSIC_AUDIO_FLAC:
{ {
// NOTE: Returns the number of samples to process // NOTE: Returns the number of samples to process
unsigned int numSamplesFlac = (unsigned int)drflac_read_s16(music->ctxFlac, numSamples*music->stream.channels, (short *)pcm); unsigned int numSamplesFlac = (unsigned int)drflac_read_s16(music->ctxFlac, samplesCount*music->stream.channels, (short *)pcm);
} break; } break;
case MUSIC_MODULE_XM: jar_xm_generate_samples_16bit(music->ctxXm, pcm, numSamples); break; case MUSIC_MODULE_XM: jar_xm_generate_samples_16bit(music->ctxXm, pcm, samplesCount); break;
case MUSIC_MODULE_MOD: jar_mod_fillbuffer(&music->ctxMod, pcm, numSamples, 0); break; case MUSIC_MODULE_MOD: jar_mod_fillbuffer(&music->ctxMod, pcm, samplesCount, 0); break;
default: break; default: break;
} }
UpdateAudioStream(music->stream, pcm, numSamples); UpdateAudioStream(music->stream, pcm, samplesCount);
music->samplesLeft -= numSamples; music->samplesLeft -= samplesCount;
if (music->samplesLeft <= 0) if (music->samplesLeft <= 0)
{ {
@ -981,7 +982,7 @@ void CloseAudioStream(AudioStream stream)
// Update audio stream buffers with data // Update audio stream buffers with data
// NOTE: Only updates one buffer per call // NOTE: Only updates one buffer per call
void UpdateAudioStream(AudioStream stream, const void *data, int numSamples) void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
{ {
ALuint buffer = 0; ALuint buffer = 0;
alSourceUnqueueBuffers(stream.source, 1, &buffer); alSourceUnqueueBuffers(stream.source, 1, &buffer);
@ -989,7 +990,7 @@ void UpdateAudioStream(AudioStream stream, const void *data, int numSamples)
// Check if any buffer was available for unqueue // Check if any buffer was available for unqueue
if (alGetError() != AL_INVALID_VALUE) if (alGetError() != AL_INVALID_VALUE)
{ {
alBufferData(buffer, stream.format, data, numSamples*stream.channels*stream.sampleSize/8, stream.sampleRate); alBufferData(buffer, stream.format, data, samplesCount*stream.channels*stream.sampleSize/8, stream.sampleRate);
alSourceQueueBuffers(stream.source, 1, &buffer); alSourceQueueBuffers(stream.source, 1, &buffer);
} }
} }

View file

@ -156,11 +156,11 @@ func LoadSoundFromWave(wave Wave) Sound {
} }
// Update sound buffer with new data // Update sound buffer with new data
func UpdateSound(sound Sound, data unsafe.Pointer, numSamples int32) { func UpdateSound(sound Sound, data unsafe.Pointer, samplesCount int32) {
csound := sound.cptr() csound := sound.cptr()
cdata := (unsafe.Pointer)(unsafe.Pointer(data)) cdata := (unsafe.Pointer)(unsafe.Pointer(data))
cnumSamples := (C.int)(numSamples) csamplesCount := (C.int)(samplesCount)
C.UpdateSound(*csound, cdata, cnumSamples) C.UpdateSound(*csound, cdata, csamplesCount)
} }
// Unload wave data // Unload wave data
@ -362,11 +362,11 @@ func InitAudioStream(sampleRate uint32, sampleSize uint32, channels uint32) Audi
} }
// Update audio stream buffers with data // Update audio stream buffers with data
func UpdateAudioStream(stream AudioStream, data unsafe.Pointer, numSamples int32) { func UpdateAudioStream(stream AudioStream, data unsafe.Pointer, samplesCount int32) {
cstream := stream.cptr() cstream := stream.cptr()
cdata := (unsafe.Pointer)(unsafe.Pointer(data)) cdata := (unsafe.Pointer)(unsafe.Pointer(data))
cnumSamples := (C.int)(numSamples) csamplesCount := (C.int)(samplesCount)
C.UpdateAudioStream(*cstream, cdata, cnumSamples) C.UpdateAudioStream(*cstream, cdata, csamplesCount)
} }
// Close audio stream and free memory // Close audio stream and free memory

View file

@ -115,7 +115,7 @@ Wave LoadWave(const char *fileName); // Load wave dat
Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
Sound LoadSound(const char *fileName); // Load sound from file Sound LoadSound(const char *fileName); // Load sound from file
Sound LoadSoundFromWave(Wave wave); // Load sound from wave data Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
void UpdateSound(Sound sound, const void *data, int numSamples);// Update sound buffer with new data void UpdateSound(Sound sound, const void *data, int samplesCount); // Update sound buffer with new data
void UnloadWave(Wave wave); // Unload wave data void UnloadWave(Wave wave); // Unload wave data
void UnloadSound(Sound sound); // Unload sound void UnloadSound(Sound sound); // Unload sound
void PlaySound(Sound sound); // Play a sound void PlaySound(Sound sound); // Play a sound
@ -146,7 +146,7 @@ float GetMusicTimePlayed(Music music); // Get current m
AudioStream InitAudioStream(unsigned int sampleRate, AudioStream InitAudioStream(unsigned int sampleRate,
unsigned int sampleSize, unsigned int sampleSize,
unsigned int channels); // Init audio stream (to stream raw audio pcm data) unsigned int channels); // Init audio stream (to stream raw audio pcm data)
void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data void UpdateAudioStream(AudioStream stream, void *data, int samplesCount); // Update audio stream buffers with data
void CloseAudioStream(AudioStream stream); // Close audio stream and free memory void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
void PlayAudioStream(AudioStream stream); // Play audio stream void PlayAudioStream(AudioStream stream); // Play audio stream

View file

@ -949,7 +949,7 @@ RLAPI Wave LoadWave(const char *fileName); // Load wa
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
RLAPI Sound LoadSound(const char *fileName); // Load sound from file RLAPI Sound LoadSound(const char *fileName); // Load sound from file
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
RLAPI void UpdateSound(Sound sound, const void *data, int numSamples);// Update sound buffer with new data RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
RLAPI void UnloadWave(Wave wave); // Unload wave data RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound RLAPI void UnloadSound(Sound sound); // Unload sound
RLAPI void PlaySound(Sound sound); // Play a sound RLAPI void PlaySound(Sound sound); // Play a sound
@ -980,7 +980,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
unsigned int sampleSize, unsigned int sampleSize,
unsigned int channels); // Init audio stream (to stream raw audio pcm data) unsigned int channels); // Init audio stream (to stream raw audio pcm data)
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int numSamples); // Update audio stream buffers with data RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream