aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-16 17:59:37 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-16 17:59:37 +0000
commit6b5fac3ca5bae016c10e236bd2bc1ca9098a0861 (patch)
tree5216b1447bf0dd8559c758e353b5c0dd40e87c4d /channel.c
parent0d0d96e8a1560887aa8035ca7eff080411fe1d3a (diff)
move some duplicated code outside an if/then/else block
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20570 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r--channel.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/channel.c b/channel.c
index f738ebb70..110e101df 100644
--- a/channel.c
+++ b/channel.c
@@ -1258,13 +1258,15 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
{
struct ast_frame *translated_frame = NULL;
struct ast_channel_spy *spy;
- struct ast_channel_spy_queue *queue;
struct channel_spy_trans *trans;
- struct ast_frame *last;
trans = (dir == SPY_READ) ? &chan->spies->read_translator : &chan->spies->write_translator;
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
+ struct ast_frame *last;
+ struct ast_frame *f1; /* the frame to append */
+ struct ast_channel_spy_queue *queue;
+
ast_mutex_lock(&spy->lock);
queue = (dir == SPY_READ) ? &spy->read_queue : &spy->write_queue;
@@ -1294,12 +1296,8 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
break;
}
}
+ f1 = translated_frame;
- for (last = queue->head; last && last->next; last = last->next);
- if (last)
- last->next = ast_frdup(translated_frame);
- else
- queue->head = ast_frdup(translated_frame);
} else {
if (f->subclass != queue->format) {
ast_log(LOG_WARNING, "Spy '%s' on channel '%s' wants format '%s', but frame is '%s', dropping\n",
@@ -1308,13 +1306,16 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
ast_mutex_unlock(&spy->lock);
continue;
}
-
- for (last = queue->head; last && last->next; last = last->next);
- if (last)
- last->next = ast_frdup(f);
- else
- queue->head = ast_frdup(f);
+ f1 = f;
}
+ /* duplicate and append f1 to the tail */
+ f1 = ast_frdup(f1);
+
+ for (last = queue->head; last && last->next; last = last->next);
+ if (last)
+ last->next = f1;
+ else
+ queue->head = f1;
queue->samples += f->samples;