]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix an issue related to synchronization of recordings when using Monitor().
authorRussell Bryant <russell@russellbryant.com>
Wed, 24 Jan 2007 00:57:28 +0000 (00:57 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 24 Jan 2007 00:57:28 +0000 (00:57 +0000)
The bug is a miscalculation of the amount to seek the stream for writing to
disk when the number of samples coming in and out of a channel do not match up.
(issue #8298, #8887, report and patch by guillecabeza, patch files created and
 testing done by whoiswes)

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

channel.c

index 4779bf8d90792fb37ee33263d2a6d309255cba92..2a22bed3caeeac2b9e4b5c705e7fbf02c2c2f98f 100644 (file)
--- a/channel.c
+++ b/channel.c
@@ -1958,9 +1958,10 @@ struct ast_frame *ast_read(struct ast_channel *chan)
 #ifndef MONITOR_CONSTANT_DELAY
                                int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;
                                if (jump >= 0) {
-                                       if (ast_seekstream(chan->monitor->read_stream, jump + f->samples, SEEK_FORCECUR) == -1)
+                                       jump = chan->outsmpl - chan->insmpl;
+                                       if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)
                                                ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
-                                       chan->insmpl += jump + 4 * f->samples;
+                                       chan->insmpl += jump + f->samples;
                                } else
                                        chan->insmpl+= f->samples;
 #else
@@ -2313,9 +2314,10 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
 #ifndef MONITOR_CONSTANT_DELAY
                                        int jump = chan->insmpl - chan->outsmpl - 4 * f->samples;
                                        if (jump >= 0) {
-                                               if (ast_seekstream(chan->monitor->write_stream, jump + f->samples, SEEK_FORCECUR) == -1)
+                                               jump = chan->insmpl - chan->outsmpl;
+                                               if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1)
                                                        ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
-                                               chan->outsmpl += jump + 4 * f->samples;
+                                               chan->outsmpl += jump + f->samples;
                                        } else
                                                chan->outsmpl += f->samples;
 #else