diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-28 19:34:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-28 19:34:49 +0300 |
commit | 6b2264b7c5f2b1dba3360eb090ad1dd0052d7afb (patch) | |
tree | 16571caccd525266e2feda348d86adceaae830e5 /src/resources/loaders | |
parent | 35d30efe7605c24765f5fdbe73a22626dc7c17c1 (diff) | |
download | manaplus-6b2264b7c5f2b1dba3360eb090ad1dd0052d7afb.tar.gz manaplus-6b2264b7c5f2b1dba3360eb090ad1dd0052d7afb.tar.bz2 manaplus-6b2264b7c5f2b1dba3360eb090ad1dd0052d7afb.tar.xz manaplus-6b2264b7c5f2b1dba3360eb090ad1dd0052d7afb.zip |
Move sdlmusic load code into musicloader.
Diffstat (limited to 'src/resources/loaders')
-rw-r--r-- | src/resources/loaders/musicloader.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp index 49ef40ef0..f9dd0fb17 100644 --- a/src/resources/loaders/musicloader.cpp +++ b/src/resources/loaders/musicloader.cpp @@ -36,7 +36,6 @@ namespace struct ResourceLoader final { std::string path; - ResourceManager::loader fun; static Resource *load(const void *const v) { @@ -51,15 +50,30 @@ namespace rl->path.c_str()); return nullptr; } - Resource *const res = rl->fun(rw, rl->path); - return res; +#ifdef USE_SDL2 + if (Mix_Music *const music = Mix_LoadMUSType_RW(rw, MUS_OGG, 1)) + { + return new SDLMusic(music, nullptr, rl->path); + } +#else + // Mix_LoadMUSType_RW was added without version changed in SDL1.2 :( + if (Mix_Music *const music = Mix_LoadMUS_RW(rw)) + { + return new SDLMusic(music, rw, rl->path); + } +#endif + else + { + logger->log("Error, failed to load music: %s", Mix_GetError()); + return nullptr; + } } }; } // namespace SDLMusic *Loader::getMusic(const std::string &idPath) { - ResourceLoader rl = { idPath, &SDLMusic::load }; + ResourceLoader rl = { idPath }; return static_cast<SDLMusic*>(resourceManager->get( idPath, ResourceLoader::load, &rl)); } |