Summary:ASTERISK-00016: [patch] Update MOH to deal with more than just MP3s
Reporter:jerjer (jerjer)Labels:
Date Opened:2003-07-26 21:29:11Date Closed:2007-09-12 21:49:12
Versions:Frequency of
Environment:Attachments:( 0) moh_sox.diff
Description:Since MP3 seems to cause so many issues with MOH it seems like it would be a good idea to make MOH playback GSM or straight WAV files.


Since Asterisk can deal with all of the various codecs on the surface it seems like this should be pretty straight forward to implement. But then again what do I know?
Comments:By: sbingner (sbingner) 2003-07-27 08:24:38

MP3 isn't causing the issues... mpg123 is causing the issues.  The problem is that mpg123 spawns a copy of itself instead of using the main thread to play the mp3.  Asterisk will then send a SIGKILL to one of the processes, which will leave the process that actually plays the mp3 as an orphan.

The best way I see to correct this, is to actually use *'s codecs to decode instead of using mpg123... would just need to have a process running from * that outputs data to a fh that can be tied to the different calls, using codec_* plugins.   I started to try to do this, but I don't know C well enough and have not had enough time to blunder my way through it.

By: Mark Spencer (markster) 2003-08-04 17:16:54

Asterisk's mp3 implementation is terrible and is likely to go away in relatively short order.

By: () 2003-08-04 18:11:41

Format the files in gsm format.  Also what about a way to switch moh context so you can switch to xmas music the day after thanks giving and switch back after newyears. :P

By: () 2003-08-04 20:51:11

Or better yet keep MP3 and write an mp3d that asterisk will talk to for its mp3 stream.  Have that be a totally seperate daemon.

By: sbingner (sbingner) 2003-08-26 23:27:48

Attached patch that will use sox and a wrapper script "/usr/bin/sox_wrapper" to play music.  In the case of a crash, this SHOULD only finish decoding one song, then close.

Requires sox compiled with mp3 support as well as a mp3 decoding library to play mp3's.  You can download compiled versions if you like at:


By: oacyscom (oacyscom) 2003-08-31 12:24:56

Why not have * convert the mp3s to wav/gsm files during startup? There wouldn't have to be an external process to handle the MOH, and the MOH system could be extended to support any file type without modifying the MOH core. Also, play order, timed announcements, overrides, etc could be controlled from within the MOH core without having to rely on the external application to play files in the right order.

By: sbingner (sbingner) 2003-09-02 00:09:10

I agree, but I don't really have the expertise in C just whip that out.... I'm working on it, and I have one that works by forking off a copy of * and running an internal decoder there.  I'll have it not forking soon but I need to go to sleep and I wanted to at least have some progress to justify the time I spent ;)

If you want to try it, you'll need to download:

You will also need both "libvorbis" and "libvorbis-devel", currently I've only got it working on "ogg" format files, but I'll get others added as soon as I have more free time.


By: jrollyson (jrollyson) 2004-01-22 22:59:12.000-0600

This is a fairly major change to the guts of app_muisiconhold, needs review by Mark, as well as some QA testing to make sure this doesn't break anything.

By: sbingner (sbingner) 2004-01-23 07:11:49.000-0600

I have since revised my view of this problem, and plan on making an external daemon that will server music to * in GSM 8KHz format.  I plan on having minimal 2-way communication between this daemon and *, and using sockets so that either end can disappear without causing the other end to do anything unwanted.  I have gotten a program to decode externally, but have not programmed the interface to * yet.  This seems like a better solution, since any problems in the mp3/whatever player will not cause * to blow up.

By: Brian West (bkw918) 2004-01-26 21:36:44.000-0600

At this time we are looking at maybe something with ogg but need to know if we can find a resample option then we can use ogg123 in place of mpg123 please repost when you try your GSM idea or maybe research the idea of using ogg.

By: jrollyson (jrollyson) 2004-01-27 02:30:26.000-0600


By: Digium Subversion (svnbot) 2007-07-20 12:08:45

Repository: asterisk-addons
Revision: 416

r416 | file | 2007-07-20 12:08:44 -0500 (Fri, 20 Jul 2007) | 6 lines

(closes issue ASTERISK-9907)
Reported by: IgorG
     mobcrash-415-1.patch uploaded by IgorG (license ASTERISK-16)
Don't crash when unloading chan_mobile when it did not completely initialize itself.