]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: ftmod_wanpipe - now receiving ftdm macros for channel polling, instead of...
authorArnaldo Pereira <arnaldo@sangoma.com>
Wed, 15 Dec 2010 19:43:40 +0000 (17:43 -0200)
committerArnaldo Pereira <arnaldo@sangoma.com>
Wed, 15 Dec 2010 19:43:40 +0000 (17:43 -0200)
         ftmod_r2 - also using ftdm macros for polling

libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c

index 154983357169ef8c31e5d825632439feb9f5119e..10e0c4ac9fc11834cd71aaaf6c80cdc5b97f2697 100644 (file)
@@ -1720,7 +1720,7 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
 
                /* deliver the actual channel events to the user now without any channel locking */
                ftdm_span_trigger_signals(span);
-#ifndef WIN32
+
                 /* figure out what event to poll each channel for. POLLPRI when the channel is down,
                  * POLLPRI|POLLIN|POLLOUT otherwise */
                memset(poll_events, 0, sizeof(short)*span->chan_count);
@@ -1732,16 +1732,12 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
                for (i = 0; citer; citer = ftdm_iterator_next(citer), i++) {
                        ftdmchan = ftdm_iterator_current(citer);
                        r2chan = R2CALL(ftdmchan)->r2chan;
-                       poll_events[i] = POLLPRI;
+                       poll_events[i] = FTDM_EVENTS;
                        if (openr2_chan_get_read_enabled(r2chan)) {
-                               poll_events[i] |= POLLIN;
+                               poll_events[i] |= FTDM_READ;
                        }
                }
-
                status = ftdm_span_poll_event(span, waitms, poll_events);
-#else
-               status = ftdm_span_poll_event(span, waitms, NULL);
-#endif
 
                /* run any span timers */
                ftdm_sched_run(r2data->sched);
index e1b665894509da5ac081350903e94f5fe6a886e8..627ef7bb67eafaa2780e047313dab8ca51041fba 100644 (file)
@@ -1051,16 +1051,34 @@ FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event)
        
        for(i = 1; i <= span->chan_count; i++) {
                ftdm_channel_t *ftdmchan = span->channels[i];
+               uint32_t chan_events = 0;
+
+               /* if the user specify which events to poll the channel for, we translate them from ftdm_wait_flag_t
+                * to events that either sangoma_waitfor_many() or poll() understands. if not, we poll for POLLPRI */
+               if (poll_events) {
+                       if (poll_events[j] & FTDM_READ) {
+                               chan_events = POLLIN;
+                       }
+                       if (poll_events[j] & FTDM_WRITE) {
+                               chan_events |= POLLOUT;
+                       }
+                       if (poll_events[j] & FTDM_EVENTS) {
+                               chan_events |= POLLPRI;
+                       }
+               } else {
+                       chan_events = POLLPRI;
+               }
+
 #ifdef LIBSANGOMA_VERSION
                if (!ftdmchan->io_data) {
                        continue; /* should never happen but happens when shutting down */
                }
                pfds[j] = ftdmchan->io_data;
-               inflags[j] = poll_events ? poll_events[j] : POLLPRI;
+               inflags[j] = chan_events;
 #else
                memset(&pfds[j], 0, sizeof(pfds[j]));
                pfds[j].fd = span->channels[i]->sockfd;
-               pfds[j].events = poll_events ? poll_events[j] : POLLPRI;
+               pfds[j].events = chan_events;
 #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! */