]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
default timeout on record to 3 seconds, reset timeout when we hear sound above the...
authorMichael Jerris <mike@jerris.com>
Fri, 22 Dec 2006 21:10:20 +0000 (21:10 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 22 Dec 2006 21:10:20 +0000 (21:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3803 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr.c

index 23ea16bd1de5dbe4bc8add7fe8da478ec73077e1..a22a67c9abf458d246f64e0746f7ab5927f39bb6 100644 (file)
@@ -346,6 +346,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
        char *p;
        const char *vval;
     time_t start = 0;
+       int org_silence_hits = 0;
 
        if (!fh) {
                fh = &lfh;
@@ -432,10 +433,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
     }
 
     if (fh->thresh) {
-        if (!fh->silence_hits) {
-            fh->silence_hits = 20;
+        if (fh->silence_hits) {
+                       fh->silence_hits = fh->samplerate * fh->silence_hits;
+               } else {
+            fh->silence_hits = fh->samplerate * 3;
         }
-    }
+               org_silence_hits = fh->silence_hits;
+       }
 
        while(switch_channel_ready(channel)) {
                switch_size_t len;
@@ -500,10 +504,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
                
             score = (uint32_t)(energy / samples);
             if (score < fh->thresh) {
-                if (!--fh->silence_hits) {
+                               fh->silence_hits -= fh->samplerate;
+                if (fh->silence_hits <= 0) {
                     break;
                 }
-            }
+                       } else {
+                               fh->silence_hits = org_silence_hits;
+                       }
         }
 
                if (!switch_test_flag(fh, SWITCH_FILE_PAUSE)) {