]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Revert "Revert "channel: Use frame deferral API for safe sleep."" 24/4424/4
authorGeorge Joseph <gjoseph@digium.com>
Mon, 14 Nov 2016 20:31:23 +0000 (15:31 -0500)
committerGeorge Joseph <gjoseph@digium.com>
Wed, 16 Nov 2016 23:46:28 +0000 (16:46 -0700)
This reverts commit 97679ee846893823cdbfd95d91cecc3c14048601.

Change-Id: Ib68f76e75882c0230378c4fed97964988e690f3c

main/channel.c

index e658c816d1cbed4152471cbca3148f63efa63e90..5cd9c164bfb5aaff633db6fa8c0631bcf8674ff8 100644 (file)
@@ -1547,9 +1547,6 @@ 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)) {
@@ -1560,10 +1557,12 @@ int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*c
        ast_channel_start_defer_frames(chan, 0);
        ast_channel_unlock(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;
                }
@@ -1578,18 +1577,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);
                }
        }
 
@@ -1598,17 +1586,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;