Skip to content

Commit

Permalink
fixup pandora compilation with SDL < 1.2.12
Browse files Browse the repository at this point in the history
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:

cef5e2e

which checks reduces the CMake version requirement for pandora
  • Loading branch information
cbeck88 committed Oct 26, 2014
1 parent 55e7ebd commit 9d48adb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/sound.cpp
Expand Up @@ -489,8 +489,14 @@ static void play_new_music()
std::map<std::string,Mix_Music*>::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";
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 9d48adb

Please sign in to comment.