diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-27 20:33:40 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-27 20:33:40 +0000 |
commit | cdcc8cbbb5336886b347b12a9969c6bc733e08fd (patch) | |
tree | 340c691b4ae2ee8e1c034c9b9fb9f4ecd2dab7d7 /main/channel.c | |
parent | df9cd44e2ab99a1fd54e0d755a748094060e8077 (diff) |
remove empty audiohook write list on channel
If a channel has an audiohook write list created on it, that
list stays on the channel until the channel is destroyed. There
is no reason to keep that list on the channel if it becomes empty.
If it is empty that just means we are doing needless translating
for every ast_read and ast_write. This patch removes the audiohook
list from the channel once it is detected to be empty on either a
read or write. If a audiohook is added back to the channel after
this list is destroyed, the list just gets recreated as if it never
existed to begin with.
(closes issue #17630)
Reported by: manvirr
Review: https://reviewboard.asterisk.org/r/799/
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@279945 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c index 62b774a66..f060fdb59 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2612,6 +2612,11 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) chan->fin = FRAMECOUNT_INC(chan->fin); done: + if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) { + /* The list gets recreated if audiohooks are added again later */ + ast_audiohook_detach_list(chan->audiohooks); + chan->audiohooks = NULL; + } ast_channel_unlock(chan); return f; } @@ -3285,6 +3290,11 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) chan->fout = FRAMECOUNT_INC(chan->fout); } done: + if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) { + /* The list gets recreated if audiohooks are added again later */ + ast_audiohook_detach_list(chan->audiohooks); + chan->audiohooks = NULL; + } ast_channel_unlock(chan); return res; } |