]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: ftmod_zt:
authorMoises Silva <moy@sangoma.com>
Sat, 1 Dec 2012 00:32:19 +0000 (19:32 -0500)
committerMoises Silva <moy@sangoma.com>
Tue, 18 Dec 2012 19:23:31 +0000 (14:23 -0500)
         Handle driver events while reading media

         ftmod_analog_em:
         Initialize read data len to avoid crashing when
         the freetdm read function does not read anything

libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c
libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c

index f7f068367384761c2f16abc379a8a2c1437ca863..8d2f1bb38f0b196004729fc609f50924a418b0e8 100644 (file)
@@ -488,11 +488,17 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj)
                        continue;
                }
 
+               len = 0;
                if (ftdm_channel_read(ftdmchan, frame, &len) != FTDM_SUCCESS) {
                        ftdm_log(FTDM_LOG_ERROR, "READ ERROR [%s]\n", ftdmchan->last_error);
                        goto done;
                }
 
+               if (0 == len) {
+                       ftdm_log(FTDM_LOG_DEBUG, "Nothing read\n");
+                       continue;
+               }
+
                if (ftdmchan->detected_tones[0]) {
                        int i;
                        
index c088c1453f0e64ab3fa41e4a8b5e8fa2928d557b..dc95c9ac088c1aec63a7efd957456363b21df864 100644 (file)
@@ -1309,8 +1309,20 @@ static FIO_READ_FUNCTION(zt_read)
                else {
                        if (errno == EAGAIN || errno == EINTR)
                                continue;
-                       if (errno == ELAST)
-                               break;
+                       if (errno == ELAST) {
+                               zt_event_t zt_event_id = 0;
+                               if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) {
+                                       ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event after ELAST on read: %s\n", strerror(errno));
+                                       r = -1;
+                                       break;
+                               }
+
+                               if (handle_dtmf_event(ftdmchan, zt_event_id)) {
+                                       /* we should enqueue this event somewhere so it can be retrieved by the user, for now, dropping it to see what it is! */
+                                       ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dropping event %d to be able to read data\n", zt_event_id);
+                               }
+                               continue;
+                       }
 
                        ftdm_log(FTDM_LOG_ERROR, "read failed: %s\n", strerror(errno));
                }