From 9d48adbfe12c174b49cdc6546f12c4f68fa8c877 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sat, 25 Oct 2014 19:34:24 -0400 Subject: [PATCH] fixup pandora compilation with SDL < 1.2.12 This was checked to compile (but not link of course) on my system, using cmake with pandora enabled, and pointed to the SDL_mixer 1.2.0 header. (the master version, not this cherry-pick) I also essentially backported this commit: cef5e2ed9ca9fcec93ae0a5f8fdf1c9fe49efb58 which checks reduces the CMake version requirement for pandora --- CMakeLists.txt | 7 ++++++- src/sound.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13972beb3381..148f417c13c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,7 +545,12 @@ if(ENABLE_TOOLS OR ENABLE_GAME OR ENABLE_TESTS) find_package( SDL_image 1.2 REQUIRED ) endif(ENABLE_TOOLS OR ENABLE_GAME OR ENABLE_TESTS) if(ENABLE_GAME OR ENABLE_TESTS) - find_package( SDL_mixer 1.2.12 REQUIRED ) + if(ENABLE_PANDORA) + find_package( SDL_mixer 1.2.0 REQUIRED ) + else(ENABLE_PANDORA) + find_package( SDL_mixer 1.2.12 REQUIRED ) + endif(ENABLE_PANDORA) + find_package( SDL_ttf 2.0.8 REQUIRED ) if(NOT MSVC) diff --git a/src/sound.cpp b/src/sound.cpp index 2464326c8e54..a796aa7e3551 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -489,8 +489,14 @@ static void play_new_music() std::map::const_iterator itor = music_cache.find(filename); if(itor == music_cache.end()) { LOG_AUDIO << "attempting to insert track '" << filename << "' into cache\n"; + +#ifndef PANDORA SDL_RWops *rwops = filesystem::load_RWops(filename); Mix_Music* const music = Mix_LoadMUSType_RW(rwops, MUS_NONE, true); // SDL takes ownership of rwops +#else + Mix_Music* const music = Mix_LoadMUS(filename.c_str()); +#endif + if(music == NULL) { ERR_AUDIO << "Could not load music file '" << filename << "': " << Mix_GetError() << "\n"; @@ -712,8 +718,12 @@ static Mix_Chunk* load_chunk(const std::string& file, channel_group group) std::string const &filename = filesystem::get_binary_file_location("sounds", file); if (!filename.empty()) { +#ifndef PANDORA SDL_RWops *rwops = filesystem::load_RWops(filename); temp_chunk.set_data(Mix_LoadWAV_RW(rwops, true)); // SDL takes ownership of rwops +#else + temp_chunk.set_data(Mix_LoadWAV(filename.c_str())); +#endif } else { ERR_AUDIO << "Could not load sound file '" << file << "'.\n"; throw chunk_load_exception();