[Asterisk-code-review] channel: Use frame deferral API for safe sleep. (asterisk[master])

George Joseph asteriskteam at digium.com
Tue Nov 8 07:04:52 CST 2016


George Joseph has uploaded a new change for review. ( https://gerrit.asterisk.org/4347 )

Change subject: channel: Use frame deferral API for safe sleep.
......................................................................

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
(cherry picked from commit d149c4b9e07eeb880d8428ad52c6fdb315cc15f5)
---
M main/channel.c
1 file changed, 6 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/47/4347/1

diff --git a/main/channel.c b/main/channel.c
index cdb6569..ba2104c 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1525,19 +1525,18 @@
 	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;
 		}
@@ -1552,18 +1551,7 @@
 				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);
 		}
 	}
 
@@ -1572,17 +1560,8 @@
 		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;

-- 
To view, visit https://gerrit.asterisk.org/4347
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42cdf205f8f29a7977e599751a57efbaac07c30e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list