This answer may come too late for Mr. Foulds, but let me disgorge my
It seems the canonical way to choose the audio output on the RPi is to
use the raspi-config, which is an interactive menuing system. Like
Mr. Foulds, I have a project where I would like the analog audio to be
the default. You cannot use raspi-config at boot (unless you want to
use something like expect, but please do not).
A look at the source code for raspi-config provides the answer:
All it does is configure the .asoundrc file for the current user
(usually pi for RPis). Notice that what really changes is the 'card'
property in the pcm.output and ctl.!default blocks. But how do we know
which "card" is the analog output?
Use 'aplay -l | grep bcm2835'. That shows you all available cards.
Use your favorite unix pattern matching tool to extract the card
number. Here's my example:
aplay -l | grep bcm2835 | grep "Headphones" | perl -lane 'print substr($F,0,1)'
This will emit the card number of the "headphones" card.
Simply create the .asoundrc file with this card number at boot time.
There is already a template for this file in the raspi-config source
linked above. I would use that.
You can change this RC file at any time. When the linux sound system
needs to route audio output, it appears to consult this file. No
rebooting is needed. If you would like to read more about the linux
sound architecture, here is the wiki:
I did a lot of web searches, but could not find this answer stated
clearly. I hope this helps.