[Home]

Summary:ASTERISK-14126: [patch] Random loss of sound when using G.729
Reporter:Andriy I Pylypenko (bamby)Labels:
Date Opened:2009-05-14 02:32:24Date Closed:2009-05-18 10:57:28
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/RTP
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) process-vad-correctly.diff
Description:I'v faced strange problem recently and have at least two confirmations for it using Asterisk 1.4.21 and 1.4.24.1.

Here is a scenario that helped to discover the problem:

The asterisk has no G.729 codec installed but all calls are made using G.729 and UAs participating in the scenario use VAD.

Initial call is placed to the Asterisk from the first UA. Asterisk plays several prompts and then places a call to another UA. After some time the calling UA sends DTMF to forcibly disconnect second call leg. Asterisk successfully disconnects the call leg and tries to play some more prompts. The problem appears during last step. With some probability the RTP stream completely stops in direction from the Asterisk to the first UA for the rest of the session, and lots of messages:

  "Dropping extra frame of G.729 since we already have a VAD frame at the end"

are printed on the console.

After examination of the source code I've found the line that I believe contains a typo. The ast_smoother_read() function checks the 'size' member of the ast_smoother structure to find out if the VAD frame is in the buffer. But the 'size' contains the buffer size (and so always has size % 10 == 0), and the length of the data in buffer is kept in the 'len' attribute. So if data containing in the buffer does not exceed the 'size' then the check in the ast_smoother_read() guarantees the NULL value to be returned regardless of buffer content.

On the other hand if the buffer contains a VAD frame then the smoother_frame_feed() function does not accept any data until the buffer is flushed.

So here we have a deadlock. To resolve the problem the check in the ast_smoother_read() has to use the 'len' instead the 'size'. I've applied this change to my Asterisk and since then no loss of the sound has been occurring.

I'm attaching my patch.
Comments:By: Andriy I Pylypenko (bamby) 2009-05-15 02:24:18

JFYI I've just glanced through the version 1.6.1.0 and trunk. Both of them contain this problem too.

By: Digium Subversion (svnbot) 2009-05-18 10:51:23

Repository: asterisk
Revision: 195206

U   branches/1.4/main/frame.c

------------------------------------------------------------------------
r195206 | file | 2009-05-18 10:51:22 -0500 (Mon, 18 May 2009) | 7 lines

Fix a typo which caused loss of audio when using G729 in some scenarios with a smoother present.

(closes issue ASTERISK-14126)
Reported by: bamby
Patches:
     process-vad-correctly.diff uploaded by bamby (license 430)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=195206

By: Digium Subversion (svnbot) 2009-05-18 10:53:26

Repository: asterisk
Revision: 195207

_U  trunk/
U   trunk/main/frame.c

------------------------------------------------------------------------
r195207 | file | 2009-05-18 10:53:26 -0500 (Mon, 18 May 2009) | 14 lines

Merged revisions 195206 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r195206 | file | 2009-05-18 12:51:22 -0300 (Mon, 18 May 2009) | 7 lines
 
 Fix a typo which caused loss of audio when using G729 in some scenarios with a smoother present.
 
 (closes issue ASTERISK-14126)
 Reported by: bamby
 Patches:
       process-vad-correctly.diff uploaded by bamby (license 430)
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=195207

By: Digium Subversion (svnbot) 2009-05-18 10:54:27

Repository: asterisk
Revision: 195208

_U  branches/1.6.0/
U   branches/1.6.0/main/frame.c

------------------------------------------------------------------------
r195208 | file | 2009-05-18 10:54:27 -0500 (Mon, 18 May 2009) | 21 lines

Merged revisions 195207 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r195207 | file | 2009-05-18 12:53:26 -0300 (Mon, 18 May 2009) | 14 lines
 
 Merged revisions 195206 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r195206 | file | 2009-05-18 12:51:22 -0300 (Mon, 18 May 2009) | 7 lines
   
   Fix a typo which caused loss of audio when using G729 in some scenarios with a smoother present.
   
   (closes issue ASTERISK-14126)
   Reported by: bamby
   Patches:
         process-vad-correctly.diff uploaded by bamby (license 430)
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=195208

By: Digium Subversion (svnbot) 2009-05-18 10:55:46

Repository: asterisk
Revision: 195209

_U  branches/1.6.1/
U   branches/1.6.1/main/frame.c

------------------------------------------------------------------------
r195209 | file | 2009-05-18 10:55:46 -0500 (Mon, 18 May 2009) | 21 lines

Merged revisions 195207 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r195207 | file | 2009-05-18 12:53:26 -0300 (Mon, 18 May 2009) | 14 lines
 
 Merged revisions 195206 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r195206 | file | 2009-05-18 12:51:22 -0300 (Mon, 18 May 2009) | 7 lines
   
   Fix a typo which caused loss of audio when using G729 in some scenarios with a smoother present.
   
   (closes issue ASTERISK-14126)
   Reported by: bamby
   Patches:
         process-vad-correctly.diff uploaded by bamby (license 430)
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=195209

By: Digium Subversion (svnbot) 2009-05-18 10:57:27

Repository: asterisk
Revision: 195212

_U  branches/1.6.2/
U   branches/1.6.2/main/frame.c

------------------------------------------------------------------------
r195212 | file | 2009-05-18 10:57:27 -0500 (Mon, 18 May 2009) | 21 lines

Merged revisions 195207 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r195207 | file | 2009-05-18 12:53:26 -0300 (Mon, 18 May 2009) | 14 lines
 
 Merged revisions 195206 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r195206 | file | 2009-05-18 12:51:22 -0300 (Mon, 18 May 2009) | 7 lines
   
   Fix a typo which caused loss of audio when using G729 in some scenarios with a smoother present.
   
   (closes issue ASTERISK-14126)
   Reported by: bamby
   Patches:
         process-vad-correctly.diff uploaded by bamby (license 430)
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=195212