Latest Posts

Topic: Possible solutions to SDL_mixer sound problems - opinions?

QCS

Topic Opener
Joined: 2009-12-29, 21:47
Posts: 256
Ranking
Tribe Member
Posted at: 2013-03-14, 19:18

Hi there,

as you may probably know, we have the problem with SDL_mixer and crashes when playing music. See this bug: https://bugs.launchpad.net/widelands/+bug/1150517

Now, over the last days, Kiscsirke, with some comments from me, developed a few solutions on this. He's now a little time constrained, so I volunteered to write this entry to provide introduction and ask for comments by fellow developers face-wink.png

Solution 1) We don't do anything. If someone has a problem, he will search and probably find one of the clues in the wiki, or the bug entry, or this forum entry, or ask in the IRC and be helped.

Solution 2) As presented in https://code.launchpad.net/~csirkeee/widelands/bug1150517_2 we can introduce a warning in CMake scripts. This would mean to copy over the FindSDL_mixer.cmake from cmake 2.8.10, change one line, and set the required CMake version for widelands to 2.8.3 (which is missing in the branch).

Solution 3) We use about 10 lines from the FindSDL_mixer.cmake from cmake 2.8.10 and do the version extraction from SDL_mixer.h by ourselves, which means we can then keep required cmake level at 2.6. The rest of the solution (the warning part) is like in 1)

Solution 4) We set the SDL_mixer requirement to 1.2.12 or above, failing build with 1.2.11 and below. Problem here is, support for this starts with cmake 2.8.10 - with lower cmake versions, it simply ignores the requirement, which makes us vulnerable like in solution 1)

Solution 5) Just like in Solution 2), we copy over the FindSDL_mixer.cmake from cmake 2.8.10, set cmake requirements for widelands to 2.8.3, but only set the SDL_mixer requirement to 1.2.12 and above like in Solution 4), which will always causes fail for cmake < 2.8.3 or SDL_mixer < 1.2.12.

Solution 6) We can use the #defines from SDL_mixer.h and guard some code in widelands sources by #ifdef to switch between one and the other implementation for SDL_mixer <1.2.12 and SDL_mixer >=1.2.12 - something which is ugly as hell, but has been done for different things like MSVC, APPLE and OPENGL specialties in the past.

Do you have any other solutions? Comments? Favourites? face-wink.png


CMake is evil.

Top Quote
gamag

Joined: 2012-01-05, 17:27
Posts: 15
Ranking
Pry about Widelands
Location: Switzerland
Posted at: 2013-03-14, 19:54

I prefer the warnings. cmake version doesn't matter for me and compiling SDL_mixer, if a distro only provides older SDL_Mixer, isn't that hard, so the #define solution doesn't make sens.


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2013-03-14, 22:59

I think we might just require a high enough SDLMixer and refuse to compile if none is found. This is a little more brutal, but will leed to less crash reports - i guess.


Top Quote
Venatrix
Avatar
Joined: 2010-10-05, 19:31
Posts: 449
Ranking
Tribe Member
Location: Germany
Posted at: 2013-03-17, 21:14

Against SirVer’s solution. As mentioned in the bugreport, Ubuntu 12.04 is affected as well, and it’s a LTS. So you would force everybody with that version to

  1. upgrade to >= 12.10,
  2. upgrade sdl-mixer to >= 1.2.12 by hand (which I know does work somehow, but don’t really know how…)
  3. leave as is and hope that someone can tell, that one has to turn off the music.

Right, the last part is not the hardest to do. Is there a chance, that you can force to disable the music, if sdl-mixer < 1.2.12?


Two is the oddest prime.

Top Quote
Kiscsirke
Avatar
Joined: 2009-12-16, 12:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2013-03-19, 14:32

<grumble> SDL_mixer 1.2.12 came out in January 2012, could've been included in Ubuntu 12.04 </grumble>

Okay, making the code conditional wasn't too terrible, about 5 lines of code, I pushed it to branch bug1150517_3. I still think it's a bit ugly, version handling like this is better in the build system I think, but with this Ubuntu thing I guess I support this solution.

Could someone with older SDL_mixer test that this works well?


Top Quote
ixprefect

Joined: 2009-02-27, 13:28
Posts: 367
Ranking
Tribe Member
Posted at: 2013-03-19, 16:25

I haven't tested your change, but it looks reasonable. I'd ask you to change two things though:

  1. Make have_to_free_rw a static function or put it into an anonymous namespace.
  2. Fix the strange "multiple indentation" in there.

Top Quote
Kiscsirke
Avatar
Joined: 2009-12-16, 12:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2013-03-19, 21:18

Right, I forgot the anonymous namespace, thanks!

Yeah, I changed the indentation until Codecheck was satisfied, but I guess that doubling there wasn't necessary, it's a bit better now face-smile.png


Top Quote