diff options
Diffstat (limited to 'main/autoservice.c')
-rw-r--r-- | main/autoservice.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/main/autoservice.c b/main/autoservice.c index d3d0333d1..26cb08582 100644 --- a/main/autoservice.c +++ b/main/autoservice.c @@ -56,6 +56,9 @@ struct asent { * it gets stopped for the last time. */ unsigned int use_count; unsigned int orig_end_dtmf_flag:1; + /*! Frames go on at the head of deferred_frames, so we have the frames + * from newest to oldest. As we put them at the head of the readq, we'll + * end up with them in the right order for the channel's readq. */ AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames; AST_LIST_ENTRY(asent) list; }; @@ -161,7 +164,7 @@ static void *autoservice_run(void *ign) } if ((dup_f = ast_frdup(defer_frame))) { - AST_LIST_INSERT_TAIL(&ents[i]->deferred_frames, dup_f, frame_list); + AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list); } break; @@ -292,10 +295,12 @@ int ast_autoservice_stop(struct ast_channel *chan) ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); } + ast_channel_lock(chan); while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) { - ast_queue_frame(chan, f); + ast_queue_frame_head(chan, f); ast_frfree(f); } + ast_channel_unlock(chan); free(as); |