[sdlsound] SDL_sound on Android

Eric Wing ewmailing at gmail.com
Fri Nov 21 04:37:40 EST 2014


On 11/3/14, Joey Carlini <moocow1452 at gmail.com> wrote:
> So, I'm working on a port of MKXP to Android, so that we could get all of
> our RPG Maker XP goodness on our mobile devices, including To The Moon and
> other homebrewed RPGs. The problem is that it uses a funky flow for how it
> works with Audio, which requires a custom patched version of SDL_sound that
> I am having a hard time building for Android. It doesn't want to take when
> I try and use a standalone toolchain to compile the latest mercurial, and
> trying to fish one out of scummvm's project is no better, so I'm just
> having a hard time figuring out what to do without rewriting the entire
> audio delivery portion of the code.
>
> https://github.com/Ancurio/mkxp/tree/master/patches/SDL_sound
>
> Any ideas, guys?
>

Hi Joey,
I'll share what I know, but at the end of the day, Android is really,
really painful.

I built SDL_sound for Android several years ago. I did not use the
CMake build system, but rewrote the build process by hand in an
Android.mk because at the time, it was the easiest way to build it
into the product I was working on at the time because they had a
monolithic Android.mk. (This was Android 1.6 days, so the toolchain
sucked even more back then.)

The hardest part were the dependencies, like mpg123. I recall x86
assembly code in that library so figuring out how to reinvent the
build system and deal with arm was a pain.

Fast forward a good number of years, and thanks to 3rd party CMake
toolchains, CMake is useable for Android. However, all the SDL_sound
dependencies don't necessarily have a CMake build system, so that will
be a pain.

Honestly, I find build systems much harder/complicated than code a
large deal of the time. So I'm actually not using SDL_sound anymore,
but rolled a native Android OpenSL ES decoder into my audio library
ALmixer (which used to solely rely on SDL_sound).

So you will need to figure out how to build the SDL_sound dependencies
and SDL_sound itself. I think SDL_sound is the easy part.

I now have the CMake build process for Android down to a point where
I've been able to document it and repeat it for multiple projects.
There are still a bunch of hoops you have to jump through. (The
biggest are setting up the standalone toolchain and setting
environmental variables.) But I find it much better than using the
Android.mk/ndk-build system.


I setup an example with ALmixer here so other people could learn from it.
https://bitbucket.org/ewing/hello-android-almixer

Additionally, OpenAL-Soft is a dependency that ALmixer depends on,
though this uses its own supplied Makefile system. This is actually a
good example of how to get CMake to find 3rd party dependencies on
Android.

Once these components are built as dynamic libraries, the final Hello
World app build process relies on the official NDK external module system to
find ALmixer and OpenAL and build appropriately.

Because there are a lot of disjoint steps, all of this is strung
together by some Perl scripts.

The README.txt contains a lot of information on how to setup things.
Android NDK development is really painful so take your time on this.
Don't expect to be able to grasp everything in 10 minutes. That said,
I think this example is one of the smoothest examples ever made of
building and using complicated 3rd party dependencies on Android with
the NDK.


I also built JavaScriptCore, which is one of the hardest, most
complicated projects I've ever had to build. I documented it here and
might be used to cross-reference what I did with ALmixer.
https://github.com/appcelerator/hyperloop/wiki/Building-JavaScriptCore-for-Android


Anyway, I hope some of this might be of some help.

Thanks,
Eric

P.S. I love To the Moon, and just played A Bird Story. Beautiful.

-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


More information about the sdlsound mailing list