diff options
author | George Joseph <gjoseph@digium.com> | 2016-11-16 17:45:05 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-11-16 17:45:05 -0600 |
commit | b8e91bb9cc3b92266c091d9e56ad2dd18b9fcffc (patch) | |
tree | 7996b50fb899fe8e997800d3964ec6da2ef4ffc0 /main/channel.c | |
parent | 99e97154bbe33c995e9e326a6d2b71e97898ad6c (diff) | |
parent | 0dc456713358d943104bcde35b85e44673d401a3 (diff) |
Merge "Revert "Revert "channel: Use frame deferral API for safe sleep."""
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/main/channel.c b/main/channel.c index 2930b895c..917ed329d 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1544,19 +1544,18 @@ int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*c int res = 0; struct timeval start; int ms; - AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames; - - AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames); /* If no other generator is present, start silencegen while waiting */ if (ast_opt_transmit_silence && !ast_channel_generatordata(chan)) { silgen = ast_channel_start_silence_generator(chan); } + ast_channel_lock(chan); + ast_channel_start_defer_frames(chan); + ast_channel_unlock(chan); + start = ast_tvnow(); while ((ms = ast_remaining_ms(start, timeout_ms))) { - struct ast_frame *dup_f = NULL; - if (cond && ((*cond)(data) == 0)) { break; } @@ -1571,18 +1570,7 @@ int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*c res = -1; break; } - - if (!ast_is_deferrable_frame(f)) { - ast_frfree(f); - continue; - } - - if ((dup_f = ast_frisolate(f))) { - if (dup_f != f) { - ast_frfree(f); - } - AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list); - } + ast_frfree(f); } } @@ -1591,17 +1579,8 @@ int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*c ast_channel_stop_silence_generator(chan, silgen); } - /* We need to free all the deferred frames, but we only need to - * queue the deferred frames if there was no error and no - * hangup was received - */ ast_channel_lock(chan); - while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) { - if (!res) { - ast_queue_frame_head(chan, f); - } - ast_frfree(f); - } + ast_channel_stop_defer_frames(chan); ast_channel_unlock(chan); return res; |