singalen / wesnoth

iOS development fork of Wesnoth
http://www.wesnoth.org/
GNU General Public License v2.0
3 stars 0 forks source link

Sound is choppy #14

Open singalen opened 7 years ago

singalen commented 7 years ago

Convert game music to mp3, this will enable hardware-accelerated playback. Verify that it's used in SDL.

GuidoBartoli commented 7 years ago

Yes, I can confirm this, music often skips and the playback is not as smooth as the desktop version.

singalen commented 6 years ago

Looks like SDL_mixer doesn't use iOS acceleration: https://hg.libsdl.org/SDL_mixer/file/d98f1d930524

File substitution-wise, here's the trick: in sound.cpp, load_chunk(), see and hack get_binary_file_location(). Transparent change that doesn't require changes all over cfgs, just put mp3-s in instead:

// mp3-s are hardware-accelerated on iOS.
if(type == "sound" && ends_with(filename, ".ogg")) {
    std::string ogg_converted = path(filename).replace_extension(".mp3").string();
    std::string converted = get_binary_file_location(type, ogg_converted);
    if(!converted.empty()) {
        return converted;
    }
}

But then, play_sound_internal() needs to be modified to use iOS' hardware:

Or maybe make a patch for SDL_mixer.

This will have to wait.

singalen commented 6 years ago

A possible code to do it, MIT licensed: https://github.com/sbooth/SFBAudioEngine/blob/master/Output/CoreAudioOutput.cpp. Some more can be googled up by "CoreAudio c++ github"