aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-14 19:18:18 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-14 19:18:18 +0000
commitc08fc582ac76ded4db1b512537251b79323a6d47 (patch)
tree80aff5d9c4a321b09429d7c005aa0e1148caf7d2 /channel.c
parent86bafe4b347369c69c64e125ed069dc432e0a9e6 (diff)
Preserve queued frames
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1328 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/channel.c b/channel.c
index 3fe2a02d7..5cc58d0f9 100755
--- a/channel.c
+++ b/channel.c
@@ -1834,10 +1834,11 @@ void ast_change_name(struct ast_channel *chan, char *newname)
static int ast_do_masquerade(struct ast_channel *original)
{
- int x;
+ int x,i;
int res=0;
char *tmp;
void *tmpv;
+ struct ast_frame *cur, *prev;
struct ast_channel_pvt *p;
struct ast_channel *clone = original->masq;
int rformat = original->readformat;
@@ -1892,7 +1893,28 @@ static int ast_do_masquerade(struct ast_channel *original)
p = original->pvt;
original->pvt = clone->pvt;
clone->pvt = p;
-
+
+ /* Save any pending frames on both sides. Start by counting
+ * how many we're going to need... */
+ prev = NULL;
+ cur = clone->pvt->readq;
+ x = 0;
+ while(cur) {
+ x++;
+ prev = cur;
+ cur = cur->next;
+ }
+ /* If we had any, prepend them to the ones already in the queue, and
+ * load up the alertpipe */
+ if (prev) {
+ prev->next = original->pvt->readq;
+ original->pvt->readq = clone->pvt->readq;
+ clone->pvt->readq = NULL;
+ if (original->pvt->alertpipe[1] > -1) {
+ for (i=0;i<x;i++)
+ write(original->pvt->alertpipe[1], &x, sizeof(x));
+ }
+ }
clone->_softhangup = AST_SOFTHANGUP_DEV;