set sound volume

This commit is contained in:
KikooDX 2022-03-06 19:19:51 +01:00
parent e097d0de73
commit a7175973b7
1 changed files with 31 additions and 20 deletions

View File

@ -100,6 +100,7 @@ int LZY_MusicDestroy(LZY_Music *music);
int LZY_MusicPlay(LZY_Music *music, int loops);
LZY_Sound *LZY_SoundLoad(const char *path);
int LZY_SoundDestroy(LZY_Sound *sound);
void LZY_SoundSetVolume(LZY_Sound *sound, float volume);
int LZY_SoundPlay(LZY_Sound *sound, int loops);
int LZY_PollEvent(LZY_Event *);
void LZY_CycleEvents(void);
@ -371,6 +372,11 @@ int LZY_SoundDestroy(LZY_Sound *sound) {
return -1;
}
void LZY_SoundSetVolume(LZY_Sound *sound, float volume) {
LZY_UNUSED(sound);
LZY_UNUSED(volume);
}
int LZY_SoundPlay(LZY_Sound *sound, int loops) {
LZY_UNUSED(sound);
LZY_UNUSED(loops);
@ -741,6 +747,16 @@ LZY_Music *LZY_MusicLoad(const char *path) {
return music;
}
int LZY_MusicDestroy(LZY_Music *music) {
if (music == NULL) {
error = "music is NULL";
return -1;
}
Mix_FreeMusic(music);
return 0;
}
int LZY_MusicPlay(LZY_Music *music, int loops) {
if (music == NULL) {
error = "music is NULL";
@ -754,16 +770,6 @@ int LZY_MusicPlay(LZY_Music *music, int loops) {
return 0;
}
int LZY_MusicDestroy(LZY_Music *music) {
if (music == NULL) {
error = "music is NULL";
return -1;
}
Mix_FreeMusic(music);
return 0;
}
LZY_Sound *LZY_SoundLoad(const char *path) {
LZY_Sound *const sound = Mix_LoadWAV(path);
if (sound == NULL)
@ -771,6 +777,21 @@ LZY_Sound *LZY_SoundLoad(const char *path) {
return sound;
}
int LZY_SoundDestroy(LZY_Sound *sound) {
if (sound == NULL) {
error = "sound is NULL";
return -1;
}
Mix_FreeChunk(sound);
return 0;
}
void LZY_SoundSetVolume(LZY_Sound *sound, float volume) {
if (sound != NULL)
Mix_VolumeChunk(sound, MIX_MAX_VOLUME * volume);
}
int LZY_SoundPlay(LZY_Sound *sound, int loops) {
if (sound == NULL) {
error = "sound is NULL";
@ -785,16 +806,6 @@ int LZY_SoundPlay(LZY_Sound *sound, int loops) {
return 0;
}
int LZY_SoundDestroy(LZY_Sound *sound) {
if (sound == NULL) {
error = "sound is NULL";
return -1;
}
Mix_FreeChunk(sound);
return 0;
}
int LZY_PollEvent(LZY_Event *e) {
SDL_Event sdl_e;