]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
evil ass bug
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 15 Jun 2007 08:16:38 +0000 (08:16 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 15 Jun 2007 08:16:38 +0000 (08:16 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@260 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/freetdm/src/fsk.c
libs/freetdm/src/include/openzap.h
libs/freetdm/src/uart.c
libs/freetdm/src/zap_analog.c
libs/freetdm/src/zap_callerid.c
libs/freetdm/src/zap_io.c

index d93316622721c84ba60bdf258c1350eb125b4cbe..df3c834787ac7855adf133c5bfa3d048511e798b 100644 (file)
@@ -309,30 +309,36 @@ dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
 
                switch (handle->state) {
                case FSK_STATE_DATA:
-                       (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
+                       {
+                               (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
+                       }
                        break;
                case FSK_STATE_CHANSEIZE:
-                       if (handle->last_bit != handle->current_bit) {
-
-
-                               handle->conscutive_state_bits++;
-                       } else {
-                               handle->conscutive_state_bits = 0;
-                       }
-                       if (handle->conscutive_state_bits > 15) {
-                               handle->state = FSK_STATE_CARRIERSIG;
-                               handle->conscutive_state_bits = 0;
+                       {
+                               if (handle->last_bit != handle->current_bit) {
+                                       handle->conscutive_state_bits++;
+                               } else {
+                                       handle->conscutive_state_bits = 0;
+                               }
+                               
+                               if (handle->conscutive_state_bits > 15) {
+                                       handle->state = FSK_STATE_CARRIERSIG;
+                                       handle->conscutive_state_bits = 0;
+                               }
                        }
                        break;
                case FSK_STATE_CARRIERSIG:
-                       if (handle->current_bit) {
-                               handle->conscutive_state_bits++;
-                       } else {
-                               handle->conscutive_state_bits = 0;
-                       }
-                       if (handle->conscutive_state_bits > 15) {
-                               handle->state = FSK_STATE_DATA;
-                               handle->conscutive_state_bits = 0;
+                       {
+                               if (handle->current_bit) {
+                                       handle->conscutive_state_bits++;
+                               } else {
+                                       handle->conscutive_state_bits = 0;
+                               }
+
+                               if (handle->conscutive_state_bits > 15) {
+                                       handle->state = FSK_STATE_DATA;
+                                       handle->conscutive_state_bits = 0;
+                               }
                        }
                        break;
                }
index 316b4d3af403495f21459f1eff31af5e3a73ce31..b68596770bf234fb0521b7d046ddba08314da3a8 100644 (file)
@@ -344,6 +344,7 @@ struct zap_channel {
        zap_filehandle_t fds[2];
        zap_fsk_data_state_t fsk;
        uint8_t fsk_buf[80];
+       uint32_t ring_count;
        struct zap_caller_data caller_data;
        struct zap_span *span;
        struct zap_io_interface *zio;
index 05a80753ecc60762d7c64b497980f81eec9bc1b0..5e0dd853505c0a53ffec3ddf7259ff5d3e90b9d5 100644 (file)
@@ -78,7 +78,7 @@ dsp_uart_handle_t *dsp_uart_create(dsp_uart_attr_t *attr)
 
        handle = malloc(sizeof (*handle));
        if (handle) {
-               memset(handle, 0, sizeof (handle));
+               memset(handle, 0, sizeof (*handle));
 
                /* fill the attributes member */
                memcpy(&handle->attr, attr, sizeof (*attr));
@@ -111,8 +111,8 @@ void dsp_uart_bit_handler(void *x, int bit)
 
        handle->data >>= 1;
        handle->data |= 0x80 * !!bit;
-       
        handle->nbits++;
+
        if (handle->nbits == 8) {
                handle->attr.bytehandler(handle->attr.bytehandler_arg, handle->data);
                handle->nbits = 0;
index 0ad28c92bda10f8bf584a4a442ea0d1fab75ee3e..adaa0ad2a036a514edea0fb3d6b2103e1deeb728 100644 (file)
@@ -426,7 +426,9 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
                        case ZAP_CHANNEL_STATE_GET_CALLERID:
                                {
                                        zap_channel_done(chan);
+                                       zap_channel_command(chan, ZAP_COMMAND_TRACE_INPUT, "/tmp/wtf.ul");
                                        zap_channel_command(chan, ZAP_COMMAND_ENABLE_CALLERID_DETECT, NULL);
+                                       continue;
                                }
                                break;
                        case ZAP_CHANNEL_STATE_RING:
@@ -619,7 +621,10 @@ static zap_status_t process_event(zap_span_t *span, zap_event_t *event)
 
                        if (event->channel->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(event->channel, ZAP_CHANNEL_INTHREAD)) {
                                zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_GET_CALLERID);
+                               event->channel->ring_count = 1;
                                zap_thread_create_detached(zap_analog_channel_run, event->channel);
+                       } else {
+                               event->channel->ring_count++;
                        }
                }
                break;
index 3e8a790053b5cc4094ff6f44c3ea7e11fd27bcdc..8940569ec0029aa63e1ae662a439049487ee8062 100644 (file)
@@ -182,6 +182,8 @@ int zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, zap_
                dsp_fsk_destroy(&state->fsk1200_handle);
        }
 
+       memset(state, 0, sizeof(*state));
+       memset(buf, 0, bufsize);
        state->buf = buf;
        state->bufsize = bufsize;
        
index 8f5e0d08f6c39112deb86df74b12aa2ec7ac25f5..b997a0156c33afa363c2a0672e0c790d79fb5698 100644 (file)
@@ -1408,13 +1408,12 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
                        if (zap_fsk_demod_feed(&zchan->fsk, sln, slen) != ZAP_SUCCESS) {
                                uint32_t type, mlen;
                                char str[128], *sp;
-
-
+                               
                                while(zap_fsk_data_parse(&zchan->fsk, &type, &sp, &mlen) == ZAP_SUCCESS) {
                                        *(str+mlen) = '\0';
                                        zap_copy_string(str, sp, ++mlen);
                                        zap_clean_string(str);
-                                       zap_log(ZAP_LOG_DEBUG, "FSK: TYPE %s LEN %d VAL [%s]\n", zap_mdmf_type2str(type), mlen-1, str);
+                                       zap_log(ZAP_LOG_ERROR, "FSK: TYPE %s LEN %d VAL [%s]\n", zap_mdmf_type2str(type), mlen-1, str);
                                        
                                        switch(type) {
                                        case MDMF_DDN: