freetdm: ftmod_zt:

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
This commit is contained in:
Moises Silva 2012-11-30 19:32:19 -05:00
parent c79509a367
commit 6f5438eded
2 changed files with 20 additions and 2 deletions

View 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;

View 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));
}