Audio Decoding

The board has a headphone socket, not line out. I've looked at the levels on my scope and it seems to have a maximum peak-to-peak voltage of about 600 mV unloaded. For what I understand that should be compatible with line level inputs, which Wikipedia claims should be 447 mV peak.

These days audio decoding can be done in software without any trouble. The only hardware support appears to be a sample-rate conversion unit. I'm not using it.

There seem to be at least a couple of potential MP3 decoding libraries: MAD and libmpg123. Apparently there is now NEON support in libmpg123 so that looks like a good choice. The Debian package currently seems to predate the NEON code so I'm building from source. The required runes seem to be:

$ CFLAGS=-mfpu=neon ./configure --with-cpu=neon --with-optimization=4
$ make; make install

Without the --with-cpu=neon, it won't generate NEON code at all. With only that, it selects the NEON assembler file but it fails to assemble because gcc thinks the CPU doesn't have those instructions. Adding the CFLAGS=-mfpu=neon resolves that.

At this point the mpg123 command-line program works (but only with ALSA, i.e. /dev/snd/). However, when I try to call libmpg123 from my own code I get Illegal Instruction errors at the start of the NEON code. With ARM "no FPU" mode I get assembler errors (apparently in Thumb mode, shift amounts cannot be specified in registers). So for now I've fallen back to --with-cpu=generic_float; this needs some more investigation.

My test DVD seems to contain AC-3 audio - apparently DVDs can use MP2, AC-3 or PCM (i.e. raw) audio. So I also need an AC-3 decoding library. It looks like liba52 is the most common, though it hasn't been updated since 2002 so I guess it's unlikely to have any NEON optimisations! It can decode the elementary stream that I get from my PES decoder, but there are four extra bytes at the start of each PES packet's payload that kept me guessing for a while.

iPlayer downloads seem to contain AAC audio, so that's another format that I need to be able to play.

Sometimes the sound device isn't found by the kernel when it starts and power-cycling is needed. (Did I read something about this somewhere?)