Summary:ASTERISK-01067: touch-tone used to terminate recording is heard on playback
Reporter:Jim Gottlieb (tokyojimu)Labels:
Date Opened:2004-02-20 20:43:00.000-0600Date Closed:2011-06-07 14:10:12
Versions:Frequency of
Environment:Attachments:( 0) app_agi.c-diff
Description:I am using commands like:
RECORD FILE 5131 pcm * 60000
in an AGI script.

The file records correctly, but the first bit of the '*' (in the above case) used to terminate the recording is heard on playback.  This is especially annoying when playing back several files strung together.


Here's how we deal with this in our custom C application:

case AST_FRAME_DTMF:  /* DTMF found */
res = f->subclass;  /* get received char */
ast_closestream(fs);  /* close stream */
newt_truncate_vfile(filename, format, 2048);

int newt_truncate_vfile (char *filename, char *format, unsigned long offset_byte)
unsigned char *cp;
struct stat mystat;

/* grab a buffer to hold full filename */
cp = (unsigned char *) malloc(strlen(filename) + strlen(format) + 5);
if (!cp)
ast_log(LOG_ERROR, "malloc failed\n");
return -1;
/* truncate off the end so that DTMF will not be heard */
/* if we have stat-age */
if (stat(cp,&mystat) != -1)
int newsize;
/* get current size */
newsize = mystat.st_size;
/* take away amount to truncate */
newsize -= offset_byte;
/* if less then 0, truncate to 0 */
if (newsize < 0) newsize = 0;
/* truncate it */
return 0;
Comments:By: Jim Gottlieb (tokyojimu) 2004-02-20 21:41:36.000-0600

OK, I fixed this (see patch).  It was easy using ast_stream_rewind and ast_truncstream.  But there's also a problem with hearing the touch-tone at the beginning of the recording too.

By: z_smurf (z_smurf) 2004-02-23 17:58:00.000-0600

The tones you are hearing only occurs when you use an analog phone connected to an ATA. If you use a real SIP-phone that sends DTMF as INFO-messages, this is not a problem.

By: Jim Gottlieb (tokyojimu) 2004-02-23 18:19:00.000-0600

True.  But how many calls come in via SIP phones.  99.999% (or more) of people calling our lines call from analog telephones.

By: Brian West (bkw918) 2004-02-24 13:29:45.000-0600

Please refer to bug 608 as its the EXACT same thing with an existing patch.  And notes on how to get this put into CVS.  (it needs to be a config option)