*/
int ast_safe_sleep(struct ast_channel *chan, int ms);
+/*!
+ * \brief Wait for a specified amount of time, looking for hangups, and do not generate silence
+ * \param chan channel to wait for
+ * \param ms length of time in milliseconds to sleep. This should never be less than zero.
+ * \details
+ * Waits for a specified amount of time, servicing the channel as required.
+ * \return returns -1 on hangup, otherwise 0.
+ * \note Unlike ast_safe_sleep this will not generate silence if Asterisk is configured to do so.
+ */
+int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms);
+
/*!
* \brief Wait for a specified amount of time, looking for hangups and a condition argument
* \param chan channel to wait for
}
/*! \brief Wait, look for hangups and condition arg */
-int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*cond)(void*), void *data)
+static int safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*cond)(void*), void *data, unsigned int generate_silence)
{
struct ast_frame *f;
struct ast_silence_generator *silgen = NULL;
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)) {
+ if (generate_silence && ast_opt_transmit_silence && !ast_channel_generatordata(chan)) {
silgen = ast_channel_start_silence_generator(chan);
}
return res;
}
+int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int (*cond)(void*), void *data)
+{
+ return safe_sleep_conditional(chan, timeout_ms, cond, data, 1);
+}
+
/*! \brief Wait, look for hangups */
int ast_safe_sleep(struct ast_channel *chan, int ms)
{
- return ast_safe_sleep_conditional(chan, ms, NULL, NULL);
+ return safe_sleep_conditional(chan, ms, NULL, NULL, 1);
+}
+
+int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms)
+{
+ return safe_sleep_conditional(chan, ms, NULL, NULL, 0);
}
struct ast_channel *ast_channel_release(struct ast_channel *chan)