Summary:ASTERISK-14683: Background always returns an AGI result of zero if interrupted by DTMF tone
Reporter:jbjon (jbjon)Labels:
Date Opened:2009-08-20 10:03:33Date Closed:2011-06-07 14:07:24
Versions:Frequency of
Description:The Background application used to return the DTMF key value if the playback of the sound file had been interrupted by a DTMF tone.

In upgrading from Asterisk 1.4.17 to, we were consistently getting an AGI response of "200 result=0" for the "EXEC Background <soundfile>" task we were executing, despite different DTMF tones being generated.

The changes made to the Background method since revision 193119 (7 May 2009) appear to have stopped it from returning the DTMF key value in the 200 AGI response.

We had initially suggested a fix to main/pbx.c in the pbx_builtin_background method that line 9169 shouldn't assign res to exten[0] but we understand from tilgham that this was intentional. However, re-compiling Asterisk with line 9169 set to our initial assumption of:
if ((exten[0] == res) && !ast_matchmore_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
does mean we once again get the desired behaviour for Background.

I'll leave the appropriate fix in your capable hands, but something around this line needs considering if a DTMF tone interrupts the Background command.


The application initiates a call using AMI Originate, specifying a custom context. This context in the dialplan has a single entry to call the FastAGI address of the application to allow 'in-call' control.
The AGI command sequence was 'ANSWER', 'EXEC Wait <time>', 'EXEC Background <soundfile>', 'WAIT FOR DIGIT'
The initial DTMF tone issued during the Background stage caused the soundfile to stop playing and AGI returned a '200 result=0'. The following 'WAIT FOR DIGIT' step would respond successfully to a DTMF tone returning the correct digit pressed in a '200 result=49' (for keypress of 1)
Comments:By: Tilghman Lesher (tilghman) 2009-08-20 10:16:02

The change you proposed is incorrect.  As explained in two other forums, you should be using STREAM FILE, not the Background application.