mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Bug fixes for Music with mini_al.
This commit is contained in:
54
src/audio.c
54
src/audio.c
@ -1426,6 +1426,13 @@ void UpdateMusicStream(Music music)
|
||||
music->loopCount--; // Decrease loop count
|
||||
PlayMusicStream(music); // Play again
|
||||
}
|
||||
else
|
||||
{
|
||||
if (music->loopCount == -1)
|
||||
{
|
||||
PlayMusicStream(music);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1506,6 +1513,13 @@ void UpdateMusicStream(Music music)
|
||||
music->loopCount--; // Decrease loop count
|
||||
PlayMusicStream(music); // Play again
|
||||
}
|
||||
else
|
||||
{
|
||||
if (music->loopCount == -1)
|
||||
{
|
||||
PlayMusicStream(music);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1537,13 +1551,21 @@ bool IsMusicPlaying(Music music)
|
||||
// Set volume for music
|
||||
void SetMusicVolume(Music music, float volume)
|
||||
{
|
||||
#if USE_MINI_AL
|
||||
SetAudioStreamVolume(music->stream, volume);
|
||||
#else
|
||||
alSourcef(music->stream.source, AL_GAIN, volume);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set pitch for music
|
||||
void SetMusicPitch(Music music, float pitch)
|
||||
{
|
||||
#if USE_MINI_AL
|
||||
SetAudioStreamPitch(music->stream, pitch);
|
||||
#else
|
||||
alSourcef(music->stream.source, AL_PITCH, pitch);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set music loop count (loop repeats)
|
||||
@ -1964,6 +1986,38 @@ void StopAudioStream(AudioStream stream)
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetAudioStreamVolume(AudioStream stream, float volume)
|
||||
{
|
||||
#if USE_MINI_AL
|
||||
AudioStreamData* internalData = (AudioStreamData*)stream.handle;
|
||||
if (internalData == NULL)
|
||||
{
|
||||
TraceLog(LOG_ERROR, "Invalid audio stream");
|
||||
return;
|
||||
}
|
||||
|
||||
internalData->volume = volume;
|
||||
#else
|
||||
alSourcef(stream.source, AL_GAIN, volume);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetAudioStreamPitch(AudioStream stream, float pitch)
|
||||
{
|
||||
#if USE_MINI_AL
|
||||
AudioStreamData* internalData = (AudioStreamData*)stream.handle;
|
||||
if (internalData == NULL)
|
||||
{
|
||||
TraceLog(LOG_ERROR, "Invalid audio stream");
|
||||
return;
|
||||
}
|
||||
|
||||
internalData->pitch = pitch;
|
||||
#else
|
||||
alSourcef(stream.source, AL_PITCH, pitch);
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user