WARNING: BREAKING: Consistency renamings
RENAMED: InitAudioStream() -> LoadAudioStream() RENAMED: CloseAudioStream() -> UnloadAudioStream()
This commit is contained in:
parent
7e68e733f5
commit
e00d2439b9
@ -32,7 +32,7 @@ int main(void)
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
// Init raw audio stream (sample rate: 22050, sample size: 16bit-short, channels: 1-mono)
|
||||
AudioStream stream = InitAudioStream(22050, 16, 1);
|
||||
AudioStream stream = LoadAudioStream(22050, 16, 1);
|
||||
|
||||
// Buffer for the single cycle waveform we are synthesizing
|
||||
short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
|
||||
@ -155,7 +155,7 @@ int main(void)
|
||||
free(data); // Unload sine wave data
|
||||
free(writeBuf); // Unload write buffer
|
||||
|
||||
CloseAudioStream(stream); // Close raw audio stream and delete buffers from RAM
|
||||
UnloadAudioStream(stream); // Close raw audio stream and delete buffers from RAM
|
||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
|
34
src/raudio.c
34
src/raudio.c
@ -1160,7 +1160,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
int sampleSize = ctxWav->bitsPerSample;
|
||||
if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
|
||||
|
||||
music.stream = InitAudioStream(ctxWav->sampleRate, sampleSize, ctxWav->channels);
|
||||
music.stream = LoadAudioStream(ctxWav->sampleRate, sampleSize, ctxWav->channels);
|
||||
music.sampleCount = (unsigned int)ctxWav->totalPCMFrameCount*ctxWav->channels;
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1179,7 +1179,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
stb_vorbis_info info = stb_vorbis_get_info((stb_vorbis *)music.ctxData); // Get Ogg file info
|
||||
|
||||
// OGG bit rate defaults to 16 bit, it's enough for compressed format
|
||||
music.stream = InitAudioStream(info.sample_rate, 16, info.channels);
|
||||
music.stream = LoadAudioStream(info.sample_rate, 16, info.channels);
|
||||
|
||||
// WARNING: It seems this function returns length in frames, not samples, so we multiply by channels
|
||||
music.sampleCount = (unsigned int)stb_vorbis_stream_length_in_samples((stb_vorbis *)music.ctxData)*info.channels;
|
||||
@ -1198,7 +1198,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
{
|
||||
drflac *ctxFlac = (drflac *)music.ctxData;
|
||||
|
||||
music.stream = InitAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
|
||||
music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
|
||||
music.sampleCount = (unsigned int)ctxFlac->totalPCMFrameCount*ctxFlac->channels;
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1216,7 +1216,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
|
||||
if (result > 0)
|
||||
{
|
||||
music.stream = InitAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
|
||||
music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
|
||||
music.sampleCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3)*ctxMp3->channels;
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1243,7 +1243,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
bits = 8;
|
||||
|
||||
// NOTE: Only stereo is supported for XM
|
||||
music.stream = InitAudioStream(AUDIO.System.device.sampleRate, bits, AUDIO_DEVICE_CHANNELS);
|
||||
music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, bits, AUDIO_DEVICE_CHANNELS);
|
||||
music.sampleCount = (unsigned int)jar_xm_get_remaining_samples(ctxXm)*2; // 2 channels
|
||||
music.looping = true; // Looping enabled by default
|
||||
jar_xm_reset(ctxXm); // make sure we start at the beginning of the song
|
||||
@ -1264,7 +1264,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
if (result > 0)
|
||||
{
|
||||
// NOTE: Only stereo is supported for MOD
|
||||
music.stream = InitAudioStream(AUDIO.System.device.sampleRate, 16, AUDIO_DEVICE_CHANNELS);
|
||||
music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, 16, AUDIO_DEVICE_CHANNELS);
|
||||
music.sampleCount = (unsigned int)jar_mod_max_samples(ctxMod)*2; // 2 channels
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1336,7 +1336,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
int sampleSize = ctxWav->bitsPerSample;
|
||||
if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
|
||||
|
||||
music.stream = InitAudioStream(ctxWav->sampleRate, sampleSize, ctxWav->channels);
|
||||
music.stream = LoadAudioStream(ctxWav->sampleRate, sampleSize, ctxWav->channels);
|
||||
music.sampleCount = (unsigned int)ctxWav->totalPCMFrameCount*ctxWav->channels;
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1353,7 +1353,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
{
|
||||
drflac *ctxFlac = (drflac *)music.ctxData;
|
||||
|
||||
music.stream = InitAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
|
||||
music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
|
||||
music.sampleCount = (unsigned int)ctxFlac->totalPCMFrameCount*ctxFlac->channels;
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1371,7 +1371,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
|
||||
if (success)
|
||||
{
|
||||
music.stream = InitAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
|
||||
music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
|
||||
music.sampleCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3)*ctxMp3->channels;
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1391,7 +1391,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
stb_vorbis_info info = stb_vorbis_get_info((stb_vorbis *)music.ctxData); // Get Ogg file info
|
||||
|
||||
// OGG bit rate defaults to 16 bit, it's enough for compressed format
|
||||
music.stream = InitAudioStream(info.sample_rate, 16, info.channels);
|
||||
music.stream = LoadAudioStream(info.sample_rate, 16, info.channels);
|
||||
|
||||
// WARNING: It seems this function returns length in frames, not samples, so we multiply by channels
|
||||
music.sampleCount = (unsigned int)stb_vorbis_stream_length_in_samples((stb_vorbis *)music.ctxData)*info.channels;
|
||||
@ -1417,7 +1417,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
bits = 8;
|
||||
|
||||
// NOTE: Only stereo is supported for XM
|
||||
music.stream = InitAudioStream(AUDIO.System.device.sampleRate, bits, 2);
|
||||
music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, bits, 2);
|
||||
music.sampleCount = (unsigned int)jar_xm_get_remaining_samples(ctxXm)*2; // 2 channels
|
||||
music.looping = true; // Looping enabled by default
|
||||
jar_xm_reset(ctxXm); // make sure we start at the beginning of the song
|
||||
@ -1455,7 +1455,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
music.ctxType = MUSIC_MODULE_MOD;
|
||||
|
||||
// NOTE: Only stereo is supported for MOD
|
||||
music.stream = InitAudioStream(AUDIO.System.device.sampleRate, 16, 2);
|
||||
music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, 16, 2);
|
||||
music.sampleCount = (unsigned int)jar_mod_max_samples(ctxMod)*2; // 2 channels
|
||||
music.looping = true; // Looping enabled by default
|
||||
musicLoaded = true;
|
||||
@ -1508,7 +1508,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
|
||||
// Unload music stream
|
||||
void UnloadMusicStream(Music music)
|
||||
{
|
||||
CloseAudioStream(music.stream);
|
||||
UnloadAudioStream(music.stream);
|
||||
|
||||
if (music.ctxData != NULL)
|
||||
{
|
||||
@ -1772,8 +1772,8 @@ float GetMusicTimePlayed(Music music)
|
||||
return secondsPlayed;
|
||||
}
|
||||
|
||||
// Init audio stream (to stream audio pcm data)
|
||||
AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels)
|
||||
// Load audio stream (to stream audio pcm data)
|
||||
AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels)
|
||||
{
|
||||
AudioStream stream = { 0 };
|
||||
|
||||
@ -1802,8 +1802,8 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||
return stream;
|
||||
}
|
||||
|
||||
// Close audio stream and free memory
|
||||
void CloseAudioStream(AudioStream stream)
|
||||
// Unload audio stream and free memory
|
||||
void UnloadAudioStream(AudioStream stream)
|
||||
{
|
||||
UnloadAudioBuffer(stream.buffer);
|
||||
|
||||
|
@ -180,9 +180,9 @@ float GetMusicTimeLength(Music music); // Get music tim
|
||||
float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
// AudioStream management functions
|
||||
AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
|
||||
void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
|
||||
bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
||||
void PlayAudioStream(AudioStream stream); // Play audio stream
|
||||
void PauseAudioStream(AudioStream stream); // Pause audio stream
|
||||
|
@ -1506,9 +1506,9 @@ RLAPI float GetMusicTimeLength(Music music); // Get mus
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
|
||||
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 bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
||||
RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream
|
||||
RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream
|
||||
|
Loading…
Reference in New Issue
Block a user