summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-11-03 16:46:41 -0500
committerGeorge Joseph <gjoseph@digium.com>2016-11-08 07:15:31 -0700
commit44f7e252397fd87420b3374df26941d7436401b3 (patch)
tree26c6bdb4b0b38214d99f1714e6a58e98560e81f4 /main
parent2e3a3545754749de21873bfdc6d1a40ec7d8893f (diff)
channel: Use frame deferral API for safe sleep.
This is another case where manual frame deferral can be replaced with centralized routines instead. Change-Id: I42cdf205f8f29a7977e599751a57efbaac07c30e
Diffstat (limited to 'main')
-rw-r--r--main/channel.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/main/channel.c b/main/channel.c
index 98359baf4..020d4d06e 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1543,19 +1543,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;
}
@@ -1570,18 +1569,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);
}
}
@@ -1590,17 +1578,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;