default timeout on record to 3 seconds, reset timeout when we hear sound above the threshold, change terms of silence timeout to be seconds.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3803 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
aae9da6464
commit
db286703a6
|
@ -346,6 +346,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||||
char *p;
|
char *p;
|
||||||
const char *vval;
|
const char *vval;
|
||||||
time_t start = 0;
|
time_t start = 0;
|
||||||
|
int org_silence_hits = 0;
|
||||||
|
|
||||||
if (!fh) {
|
if (!fh) {
|
||||||
fh = &lfh;
|
fh = &lfh;
|
||||||
|
@ -432,9 +433,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fh->thresh) {
|
if (fh->thresh) {
|
||||||
if (!fh->silence_hits) {
|
if (fh->silence_hits) {
|
||||||
fh->silence_hits = 20;
|
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)) {
|
while(switch_channel_ready(channel)) {
|
||||||
|
@ -500,9 +504,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||||
|
|
||||||
score = (uint32_t)(energy / samples);
|
score = (uint32_t)(energy / samples);
|
||||||
if (score < fh->thresh) {
|
if (score < fh->thresh) {
|
||||||
if (!--fh->silence_hits) {
|
fh->silence_hits -= fh->samplerate;
|
||||||
|
if (fh->silence_hits <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fh->silence_hits = org_silence_hits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue