The mpg321 package is not cabable of producing the proper raw stream format required by Asterisk. Mpg321 simply ignores unknown commandline switches and produces a raw stream with the same sample rate and chanels as the input file (e.g. 44100, stereo). Asterisk needs a single channel (mono) raw stream with 8000Hz sample rate.
As I did not want to start installing another mp3 player software on that box, I made s small wrapper script to combine (the existing) mpg321 and sox to generate the proper output format:
mpg321 -q -s -z --wav - $* | sox -t wav - -t raw -c1 -r8000 -w2 - 2>/dev/null;
My musiconhold.conf looks:
; Music on hold class definitions
default => custom:/home/hb9xar/asterisk/var/lib/asterisk/mohmp3,/usr/local/bin/asterisk_play.sh
- loud => mp3
- random => quietmp3