From 3764664b20b8b85a6c0a0ec3a098251c3bcec4a0 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 13 Feb 2024 15:31:46 +0100 Subject: Fixed music playback A faulty version check was disabling music loading entirely. --- src/resources/music.cpp | 20 ++++---------------- src/resources/soundeffect.cpp | 8 +++----- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/resources/music.cpp b/src/resources/music.cpp index c6760865..12c723bd 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -35,28 +35,16 @@ Music::~Music() Resource *Music::load(SDL_RWops *rw) { -#if SDL_MIXER_MAJOR_VERSION >= 1 &&\ - SDL_MIXER_MINOR_VERSION >= 2 &&\ - SDL_MIXER_PATCHLEVEL >= 9 - if (Mix_Music *music = Mix_LoadMUS_RW(rw)) + if (Mix_Music *music = Mix_LoadMUS_RW(rw, 1)) { return new Music(music); } - else - { - logger->log("Error, failed to load music: %s", Mix_GetError()); - return 0; - } -#else - SDL_FreeRW(rw); + + logger->log("Error, failed to load music: %s", Mix_GetError()); return nullptr; -#endif } bool Music::play(int loops, int fadeIn) { - if (fadeIn > 0) - return Mix_FadeInMusic(mMusic, loops, fadeIn); - else - return Mix_PlayMusic(mMusic, loops); + return Mix_FadeInMusic(mMusic, loops, fadeIn); } diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index 782d79d1..8f8cdfc5 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -37,11 +37,9 @@ Resource *SoundEffect::load(SDL_RWops *rw) { return new SoundEffect(tmpSoundEffect); } - else - { - logger->log("Error, failed to load sound effect: %s", Mix_GetError()); - return nullptr; - } + + logger->log("Error, failed to load sound effect: %s", Mix_GetError()); + return nullptr; } bool SoundEffect::play(int loops, int volume, int channel) -- cgit v1.2.3-70-g09d2