From f073f648b87d45e4729969fd2d83695c300757d1 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Thu, 3 Nov 2016 16:36:13 -0500 Subject: Add API for channel frame deferral. There are several places in Asterisk that have duplicated logic for deferring important frames until later. This commit adds a couple of API calls to facilitate this automatically. ast_channel_start_defer_frames(): Future reads of deferrable frames on this channel will be deferred until later. ast_channel_stop_defer_frames(): Any frames that have been deferred get requeued onto the channel. ASTERISK-26343 Change-Id: I3e1b87bc6796f222442fa6f7d1b6a4706fb33641 --- include/asterisk/channel.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'include/asterisk/channel.h') diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index ff92cc878..e5f53f082 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -967,6 +967,11 @@ enum { * The channel is executing a subroutine or macro */ AST_FLAG_SUBROUTINE_EXEC = (1 << 27), + /*! + * The channel is currently in an operation where + * frames should be deferred. + */ + AST_FLAG_DEFER_FRAMES = (1 << 28), }; /*! \brief ast_bridge_config flags */ @@ -4671,4 +4676,37 @@ enum ast_channel_error { */ enum ast_channel_error ast_channel_errno(void); +/*! + * \brief Retrieve the deferred read queue. + */ +struct ast_readq_list *ast_channel_deferred_readq(struct ast_channel *chan); + +/*! + * \brief Start deferring deferrable frames on this channel + * + * Sometimes, a channel gets entered into a mode where a "main" application + * is tasked with servicing frames on the channel, but that application does + * not need to act on those frames. However, it would be imprudent to simply + * drop important frames. This function can be called so that important frames + * will be deferred, rather than placed in the channel frame queue as normal. + * + * \pre chan MUST be locked before calling + * + * \param chan The channel on which frames should be deferred + */ +void ast_channel_start_defer_frames(struct ast_channel *chan); + +/*! + * \brief Stop deferring deferrable frames on this channel + * + * When it is time to stop deferring frames on the channel, all deferred frames + * will be queued onto the channel's read queue so that the next servicer of + * the channel can handle those frames as necessary. + * + * \pre chan MUST be locked before calling + * + * \param chan The channel on which to stop deferring frames. + */ +void ast_channel_stop_defer_frames(struct ast_channel *chan); + #endif /* _ASTERISK_CHANNEL_H */ -- cgit v1.2.3