Fix minor voicemail silence detect issues
authorMark Spencer <markster@digium.com>
Tue, 13 May 2003 02:25:10 +0000 (02:25 +0000)
committerMark Spencer <markster@digium.com>
Tue, 13 May 2003 02:25:10 +0000 (02:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1011 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail2.c

index 50d7bc4..690f021 100755 (executable)
@@ -573,7 +573,7 @@ static int play_and_record(struct ast_channel *chan, char *playfile, char *recor
        int totalsilence = 0;
        int dspsilence = 0;
        int gotsilence = 0;             /* did we timeout for silence? */
        int totalsilence = 0;
        int dspsilence = 0;
        int gotsilence = 0;             /* did we timeout for silence? */
-       
+       int rfmt=0;     
        
        ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
        snprintf(comment,sizeof(comment),"Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
        
        ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
        snprintf(comment,sizeof(comment),"Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
@@ -622,7 +622,7 @@ static int play_and_record(struct ast_channel *chan, char *playfile, char *recor
        ast_dsp_set_threshold(sildet, 50);
        
        if (maxsilence > 0) {
        ast_dsp_set_threshold(sildet, 50);
        
        if (maxsilence > 0) {
-               //rfmt = chan->readformat;
+               rfmt = chan->readformat;
                res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
                if (res < 0) {
                        ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
                res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
                if (res < 0) {
                        ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
@@ -717,13 +717,18 @@ static int play_and_record(struct ast_channel *chan, char *playfile, char *recor
        for (x=0;x<fmtcnt;x++) {
                if (!others[x])
                        break;
        for (x=0;x<fmtcnt;x++) {
                if (!others[x])
                        break;
-               if (gotsilence)
-                       ast_stream_rewind(others[x], totalsilence-1000);
+               if (totalsilence)
+                       ast_stream_rewind(others[x], totalsilence+200);
                else
                        ast_stream_rewind(others[x], 1000);
                ast_truncstream(others[x]);
                ast_closestream(others[x]);
        }
                else
                        ast_stream_rewind(others[x], 1000);
                ast_truncstream(others[x]);
                ast_closestream(others[x]);
        }
+       if (rfmt) {
+               if (ast_set_read_format(chan, rfmt)) {
+                       ast_log(LOG_WARNING, "Unable to restore format %d to channel '%s'\n", rfmt, chan->name);
+               }
+       }
        if (outmsg) {
                if (outmsg > 1) {
                /* Let them know it worked */
        if (outmsg) {
                if (outmsg > 1) {
                /* Let them know it worked */