static void playtone(struct ast_channel *chan, int tone, int len) { char dtmf[20]; snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len); ast_playtones_start(chan, 0, dtmf, 0); ast_safe_sleep(chan, len); ast_playtones_stop(chan); }
/*! * \brief Send a single tone burst for a specified duration and frequency. * \since 11.0 * * \param chan Asterisk Channel * \param tone_freq Frequency of the tone to send * \param tone_duration Tone duration in ms * \param delay Delay before sending the tone * * \retval 0 success * \retval -1 failure */ static int send_tone_burst(struct ast_channel *chan, const char *tone_freq, int tone_duration, int delay) { if (delay && ast_safe_sleep(chan, delay)) { return -1; } if (ast_playtones_start(chan, toneloudness, tone_freq, 0)) { return -1; } if (ast_safe_sleep(chan, tone_duration)) { return -1; } ast_playtones_stop(chan); return 0; }
/* * StopPlaylist command stuff */ static int handle_stopplaytones(struct ast_channel *chan, void *data) { ast_playtones_stop(chan); return 0; }