Summary:ASTERISK-04756: All sounds are stopped since 1.0.7-stable
Reporter:Arcadiy Ivanov (arcivanov)Labels:
Date Opened:2005-08-02 09:57:19Date Closed:2008-01-15 15:43:42.000-0600
Versions:Frequency of
Environment:Attachments:( 0) extension_+_iax2_debug.txt
Description:I have the following setup:
- I connect outgoing calls via Voicepulse IAX2
- The calls are bridged via Digium FXS interface
Thus, FXS is being picked up, some number processing occurs, then IAX2 is dialed. The problem is that as soon as the IAX2 channel is dialed all sounds are stopped almost immediately, with only one or no rings being heard in FXS. Then FXS enjoys silence until the call is answered or busy is indicated or failure.

This was not always the case. In 1.0.7 the sounds were not stopped and ringing or music-on-hold played until connected/busy/failed. Some time during 1.0.7-stable and after that the behavior changed and the sounds now are always stopped.

This problem seems similar to bug ASTERISK-3813840.
Comments:By: Arcadiy Ivanov (arcivanov) 2005-08-02 09:59:38

The following is the Asterisk verbose log with the actual number removed:

   -- Starting simple switch on 'Zap/2-1'
   -- Executing Macro("Zap/2-1", "dial-voicepulse|1XXXXXXXXXX") in new stack
   -- Executing Macro("Zap/2-1", "dial-failover-number|IAX2/voicepulse-out-01|IAX2/voicepulse-out-02|1XXXXXXXXXX") in new stack
   -- Executing ChanIsAvail("Zap/2-1", "IAX2/voicepulse-out-01&IAX2/voicepulse-out-02") in new stack
   -- Hungup 'IAX2/voicepulse-out-01/3'
   -- Executing Cut("Zap/2-1", "selected_channel=AVAILCHAN|/|1&2") in new stack
   -- Executing Dial("Zap/2-1", "IAX2/voicepulse-out-01/1XXXXXXXXXX||r") in new stack
   -- Called voicepulse-out-01/1XXXXXXXXXX
   -- Call accepted by (format ulaw)
   -- Format for call is ulaw
   -- IAX2/voicepulse-out-01/4 stopped sounds
   -- IAX2/voicepulse-out-01/4 is making progress passing it to Zap/2-1
   -- Hungup 'IAX2/voicepulse-out-01/4'
 == No one is available to answer at this time
   -- Executing Hangup("Zap/2-1", "") in new stack
 == Spawn extension (macro-dial-failover-number, s, 4) exited non-zero on 'Zap/2-1' in macro 'dial-failover-number'
 == Spawn extension (macro-dial-voicepulse, s, 1) exited non-zero on 'Zap/2-1' in macro 'dial-voicepulse'
 == Spawn extension (internal-common, 1XXXXXXXXXX, 1) exited non-zero on 'Zap/2-1'
   -- Hungup 'Zap/2-1'
   -- Starting simple switch on 'Zap/2-1'
   -- Hungup 'Zap/2-1'

By: Arcadiy Ivanov (arcivanov) 2005-08-02 10:05:46

I've also attached as a file the same extension log as above with IAX2 debugging enabled.

By: Arcadiy Ivanov (arcivanov) 2005-08-03 12:24:20

Ok, this bug/feature happens in app_dial.c, lines 348-352.
The control_frame is received (AST_FRAME_CONTROL), and switch statement is going over the control subclass. If the subclass is -1 (or if we have an unsigned byte 255), then the sounds are stopped. The actual code looks like this:

case -1:
   if (!outgoing->ringbackonly || !outgoing->musiconhold) {
       if (option_verbose > 2)
           ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", o->chan->name);
       ast_indicate(in, -1);
       (*sentringing) = 0;

Strangely, this is the only subclass value which does not have a macro associated with it. All other cases look like this:

   /* Ignore going off hook */

Anybody knows what subclass 255 (-1) does?

By: Arcadiy Ivanov (arcivanov) 2005-08-03 12:35:28

Here's what changed since 1.0.7 release in that portion of app_dial.c:

Ver 1.0.7:
if (!outgoing->ringbackonly && !outgoing->musiconhold) {

Ver 1.0.9:
if (!outgoing->ringbackonly || !outgoing->musiconhold) {

Whats the intended behavior here?

By: Arcadiy Ivanov (arcivanov) 2005-08-03 13:15:37

The only app_dial changelog item I found between 1.0.7 and higher versions is this:

-- app_dial
  -- There was a problem where text frames would not be forwarded before the channel has been answered.

Can it be possible that the logic change fixed the problem with text frames and broke the ringing/MOH?

By: Arcadiy Ivanov (arcivanov) 2005-08-03 13:24:48

I've just tested a version of app_dial.c where the statement
      if (!outgoing->ringbackonly || !outgoing->musiconhold) {
is changed to
      if (!outgoing->ringbackonly && !outgoing->musiconhold) {

The ringing/MOH problem is solved with && instead of || but as stated in the note above will probably break text frames.

By: Mark Spencer (markster) 2005-08-03 13:26:36

Please confirm this is not an issue in head.  thanks!

By: Arcadiy Ivanov (arcivanov) 2005-08-03 13:54:43

In the HEAD the test looks as:
      if (!ast_test_flag(outgoing, DIAL_RINGBACKONLY | DIAL_MUSICONHOLD)) {

Unfortunately, I have no knowledge of Asterisk internals even to compare the above with either
      if (!outgoing->ringbackonly || !outgoing->musiconhold) {
      if (!outgoing->ringbackonly && !outgoing->musiconhold) {

My guess would be that ast_test_flag tests the presence of BOTH flags thus having the same logic as (!outgoing->ringbackonly && !outgoing->musiconhold), but once again, I'm guessing.

By: Tilghman Lesher (tilghman) 2005-08-03 15:40:30

This logic:

if (!ast_test_flag(outgoing, DIAL_RINGBACKONLY | DIAL_MUSICONHOLD)) {

is the same as:

if (! (ringbackonly || musiconhold)) {

which is the same as:

if (!ringbackonly && !musiconhold) {

As far as the change, it was introduced by bug# 3543.

By: Tilghman Lesher (tilghman) 2005-08-03 15:43:30

In fact, drumkilla's final note on 3543 tends to suggest that he accidently toasted the logic, so && should be correct, here.

By: Mark Spencer (markster) 2005-08-03 15:50:43

Okay, as i interpret the response, this is not an issue in head, so i'm marking it for stable only.

By: Russell Bryant (russell) 2005-08-04 16:23:32

arcivanov: Thank you for the help tracking this down!

It has been fixed in the 1.0 branch

By: Digium Subversion (svnbot) 2008-01-15 15:43:42.000-0600

Repository: asterisk
Revision: 6281

U   branches/v1-0/apps/app_dial.c

r6281 | russell | 2008-01-15 15:43:42 -0600 (Tue, 15 Jan 2008) | 2 lines

fix broken logic (bug ASTERISK-4756)