]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
When ending a recording with silence detection, remember to reduce the duration.
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 2 Mar 2009 23:09:01 +0000 (23:09 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 2 Mar 2009 23:09:01 +0000 (23:09 +0000)
The end of the recording is correspondingly trimmed, but the duration was not
trimmed by the number of seconds trimmed, so the saved duration was necessarily
longer than the actual soundfile duration.
(closes issue #14406)
 Reported by: sasargen
 Patches:
       20090226__bug14406.diff.txt uploaded by tilghman (license 14)
 Tested by: sasargen

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@179468 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/app.c

index bcecff56877b363bdb5596219945ab1c0ede8216..2c448d549265e2239d11d173d5b88af5ffd54180 100644 (file)
@@ -731,8 +731,16 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
                         * off the recording.  However, if we ended with '#', we don't want
                         * to trim ANY part of the recording.
                         */
-                       if (res > 0 && totalsilence)
+                       if (res > 0 && totalsilence) {
                                ast_stream_rewind(others[x], totalsilence - 200);
+                               /* Reduce duration by a corresponding amount */
+                               if (x == 0 && *duration) {
+                                       *duration -= (totalsilence - 200) / 1000;
+                                       if (*duration < 0) {
+                                               *duration = 0;
+                                       }
+                               }
+                       }
                        ast_truncstream(others[x]);
                        ast_closestream(others[x]);
                }