]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
kindof working t203 timer
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 23 May 2007 19:47:35 +0000 (19:47 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 23 May 2007 19:47:35 +0000 (19:47 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@114 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/isdn/include/Q921.h
libs/openzap/src/zap_isdn.c

index 672f60b0c5886bd5b6f6fdb51664d2127c670f9c..793d256c6b6e8cb4c8460ec0a51d85872f3aacdb 100644 (file)
@@ -131,7 +131,7 @@ int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, L2INT size);
 int Q921Rx12(L2TRUNK trunk);
 int Q921Rx32(L2TRUNK trunk, L2UCHAR * Mes, L2INT Size);
 int Q921Start(L2TRUNK trunk);
-void Q921SetGetTimeCB(L2ULONG (*callback)());\r
-void Q921TimerTick(L2TRUNK trunk);\r
+void Q921SetGetTimeCB(L2ULONG (*callback)());
+void Q921TimerTick(L2TRUNK trunk);
 #endif
 
index 978504a1e97a14d10181dab8b51648fb9e5e54ab..e1f59d45655864353d49239874224cf0dd76c61b 100644 (file)
 #include "zap_isdn.h"
 #include "Q931.h"
 #include "Q921.h"
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+
 #define LINE "--------------------------------------------------------------------------------"
 #define IODEBUG
 
+static L2ULONG zap_time_now()
+{
+#ifdef WIN32
+       return timeGetTime();
+#else
+       struct timeval tv;
+       gettimeofday(&tv, NULL);
+       return ((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
+#endif
+}
+
 static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
 {
        zap_log(ZAP_LOG_ERROR, "ERROR: %d %d %d", id, p1, p2);
@@ -93,6 +110,10 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
        unsigned char buf[1024];
        zap_size_t len = sizeof(buf);
 
+#ifdef WIN32
+    timeBeginPeriod(1);
+#endif
+
        zap_log(ZAP_LOG_DEBUG, "ISDN thread starting.\n");
 
        Q921Start(&data->q921);
@@ -100,7 +121,9 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
        while(zap_test_flag(data, ZAP_ISDN_RUNNING)) {
                zap_wait_flag_t flags = ZAP_READ;
                zap_status_t status = zap_channel_wait(data->dchan, &flags, 100);
-               
+
+               Q921TimerTick(&data->q921);
+
                switch(status) {
                case ZAP_FAIL:
                        {
@@ -144,6 +167,10 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
        zap_channel_close(&data->dchans[1]);
        zap_clear_flag(span->isdn_data, ZAP_ISDN_RUNNING);
 
+#ifdef WIN32
+    timeEndPeriod(1);
+#endif
+
        zap_log(ZAP_LOG_DEBUG, "ISDN thread ended.\n");
        return NULL;
 }
@@ -151,6 +178,8 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
 zap_status_t zap_isdn_init(void)
 {
        Q931Initialize();
+
+       Q921SetGetTimeCB(zap_time_now);
        
        return ZAP_SUCCESS;
 }