merged threaded ftmod_r2.c with non-threaded version from moy and added support for receiving the events to wait for, on ftdm_span_poll_event(), which keeps its default behavior: POLLPRI if NULL is passed

This commit is contained in:
Arnaldo Pereira 2010-09-23 17:51:45 -03:00
parent 1c9fe263d6
commit f825d1b0ad
9 changed files with 746 additions and 346 deletions

View File

@ -895,12 +895,12 @@ FT_DECLARE(ftdm_status_t) ftdm_span_find(uint32_t id, ftdm_span_t **span)
}
FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms)
FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms, short *poll_events)
{
assert(span->fio != NULL);
if (span->fio->poll_event) {
return span->fio->poll_event(span, ms);
return span->fio->poll_event(span, ms, poll_events);
} else {
ftdm_log(FTDM_LOG_ERROR, "poll_event method not implemented in module %s!", span->fio->name);
}

View File

@ -966,7 +966,7 @@ static void *ftdm_analog_run(ftdm_thread_t *me, void *obj)
int waitms = 1000;
ftdm_status_t status;
if ((status = ftdm_span_poll_event(span, waitms)) != FTDM_FAIL) {
if ((status = ftdm_span_poll_event(span, waitms, NULL)) != FTDM_FAIL) {
errs = 0;
}

View File

@ -657,7 +657,7 @@ static void *ftdm_analog_em_run(ftdm_thread_t *me, void *obj)
int waitms = 10;
ftdm_status_t status;
status = ftdm_span_poll_event(span, waitms);
status = ftdm_span_poll_event(span, waitms, NULL);
switch(status) {
case FTDM_SUCCESS:

View File

@ -1558,7 +1558,7 @@ static __inline__ void check_events(ftdm_span_t *span)
{
ftdm_status_t status;
status = ftdm_span_poll_event(span, 5);
status = ftdm_span_poll_event(span, 5, NULL);
switch(status) {
case FTDM_SUCCESS:

View File

@ -890,7 +890,7 @@ static __inline__ void check_events(ftdm_span_t *span)
{
ftdm_status_t status;
status = ftdm_span_poll_event(span, 5);
status = ftdm_span_poll_event(span, 5, NULL);
switch(status) {
case FTDM_SUCCESS:

File diff suppressed because it is too large Load Diff

View File

@ -1725,7 +1725,7 @@ static __inline__ ftdm_status_t check_events(ftdm_span_t *span, int ms_timeout)
ftdm_status_t status;
ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
status = ftdm_span_poll_event(span, ms_timeout);
status = ftdm_span_poll_event(span, ms_timeout, NULL);
switch(status) {
case FTDM_SUCCESS:

View File

@ -865,11 +865,11 @@ FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event)
continue; /* should never happen but happens when shutting down */
}
pfds[j] = ftdmchan->mod_data;
inflags[j] = POLLPRI;
inflags[j] = poll_events ? poll_events[j] : POLLPRI;
#else
memset(&pfds[j], 0, sizeof(pfds[j]));
pfds[j].fd = span->channels[i]->sockfd;
pfds[j].events = POLLPRI;
pfds[j].events = poll_events ? poll_events[j] : POLLPRI;
#endif
/* The driver probably should be able to do this wink/flash/ringing by itself this is sort of a hack to make it work! */

View File

@ -459,7 +459,7 @@ struct ftdm_memory_handler {
#define FIO_CHANNEL_GET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status)
#define FIO_SPAN_SET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status)
#define FIO_SPAN_GET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status)
#define FIO_SPAN_POLL_EVENT_ARGS (ftdm_span_t *span, uint32_t ms)
#define FIO_SPAN_POLL_EVENT_ARGS (ftdm_span_t *span, uint32_t ms, short *poll_events)
#define FIO_SPAN_NEXT_EVENT_ARGS (ftdm_span_t *span, ftdm_event_t **event)
#define FIO_SIGNAL_CB_ARGS (ftdm_sigmsg_t *sigmsg)
#define FIO_EVENT_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_event_t *event)
@ -820,12 +820,13 @@ FT_DECLARE(void) ftdm_channel_flush_dtmf(ftdm_channel_t *ftdmchan);
*
* \param span The span to wait events for
* \param ms Milliseconds timeout
* \param poll_events Array of events to poll for, for each channel on the span
*
* \retval FTDM_SUCCESS success (at least one event available)
* \retval FTDM_TIMEOUT Timed out waiting for events
* \retval FTDM_FAIL failure
*/
FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms);
FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms, short *poll_events);
/*!
* \brief Find a span by its id