Various IAX2 fixes
authorMark Spencer <markster@digium.com>
Mon, 13 Jun 2005 08:48:17 +0000 (08:48 +0000)
committerMark Spencer <markster@digium.com>
Mon, 13 Jun 2005 08:48:17 +0000 (08:48 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5901 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/iax2-parser.c

index 17d1f34..5d446f4 100755 (executable)
@@ -94,10 +94,11 @@ static int nochecksums = 0;
 /*
  * Uncomment to try experimental IAX bridge optimization,
  * designed to reduce latency when IAX calls cannot
 /*
  * Uncomment to try experimental IAX bridge optimization,
  * designed to reduce latency when IAX calls cannot
- * be trasnferred
+ * be trasnferred -- obsolete
  */
 
  */
 
-#define BRIDGE_OPTIMIZATION 
+/* #define BRIDGE_OPTIMIZATION  */
+
 
 #define PTR_TO_CALLNO(a) ((unsigned short)(unsigned long)(a))
 #define CALLNO_TO_PTR(a) ((void *)(unsigned long)(a))
 
 #define PTR_TO_CALLNO(a) ((unsigned short)(unsigned long)(a))
 #define CALLNO_TO_PTR(a) ((void *)(unsigned long)(a))
@@ -2319,7 +2320,7 @@ static int schedule_delivery(struct iax_frame *fr, int reallydeliver, int update
 
        if(fr->af.frametype == AST_FRAME_VOICE) {
                type = JB_TYPE_VOICE;
 
        if(fr->af.frametype == AST_FRAME_VOICE) {
                type = JB_TYPE_VOICE;
-                len = ast_codec_get_samples(&fr->af) / 8;
+               len = ast_codec_get_samples(&fr->af) / 8;
        } else if(fr->af.frametype == AST_FRAME_CNG) {
                type = JB_TYPE_SILENCE;
        }
        } else if(fr->af.frametype == AST_FRAME_CNG) {
                type = JB_TYPE_SILENCE;
        }
@@ -2347,9 +2348,9 @@ static int schedule_delivery(struct iax_frame *fr, int reallydeliver, int update
 
                iaxs[fr->callno]->jbid = -1;
 
 
                iaxs[fr->callno]->jbid = -1;
 
-                /* deliver this frame now */
-                __do_deliver(fr);
-                return 0;
+               /* deliver this frame now */
+               __do_deliver(fr);
+               return 0;
 
        }
 
 
        }
 
@@ -6249,13 +6250,17 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                                                                forward_delivery(&fr);
                                                                        } else {
                                                                                duped_fr = iaxfrdup2(&fr);
                                                                                forward_delivery(&fr);
                                                                        } else {
                                                                                duped_fr = iaxfrdup2(&fr);
-                                                                               schedule_delivery(duped_fr, 1, updatehistory, 1);
-                                                                               fr.ts = duped_fr->ts;
+                                                                               if (duped_fr) {
+                                                                                       schedule_delivery(duped_fr, 1, updatehistory, 1);
+                                                                                       fr.ts = duped_fr->ts;
+                                                                               }
                                                                        }
 #else
                                                                        duped_fr = iaxfrdup2(&fr);
                                                                        }
 #else
                                                                        duped_fr = iaxfrdup2(&fr);
-                                                                       schedule_delivery(duped_fr, 1, updatehistory, 1);
-                                                                       fr.ts = duped_fr->ts;
+                                                                       if (duped_fr) {
+                                                                               schedule_delivery(duped_fr, 1, updatehistory, 1);
+                                                                               fr.ts = duped_fr->ts;
+                                                                       }
 #endif
                                                                        if (iaxs[fr.callno]->last < fr.ts) {
                                                                                iaxs[fr.callno]->last = fr.ts;
 #endif
                                                                        if (iaxs[fr.callno]->last < fr.ts) {
                                                                                iaxs[fr.callno]->last = fr.ts;
@@ -7413,13 +7418,17 @@ retryowner2:
                forward_delivery(&fr);
        } else {
                duped_fr = iaxfrdup2(&fr);
                forward_delivery(&fr);
        } else {
                duped_fr = iaxfrdup2(&fr);
-               schedule_delivery(duped_fr, 1, updatehistory, 0);
-               fr.ts = duped_fr->ts;
+               if (duped_fr) {
+                       schedule_delivery(duped_fr, 1, updatehistory, 0);
+                       fr.ts = duped_fr->ts;
+               }
        }
 #else
        duped_fr = iaxfrdup2(&fr);
        }
 #else
        duped_fr = iaxfrdup2(&fr);
-       schedule_delivery(duped_fr, 1, updatehistory, 0);
-       fr.ts = duped_fr->ts;
+       if (duped_fr) {
+               schedule_delivery(duped_fr, 1, updatehistory, 0);
+               fr.ts = duped_fr->ts;
+       }
 #endif
 
        if (iaxs[fr.callno]->last < fr.ts) {
 #endif
 
        if (iaxs[fr.callno]->last < fr.ts) {
index 2853c76..1cd0f40 100755 (executable)
@@ -880,7 +880,7 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
        if (fr->af.datalen) {
 #if __BYTE_ORDER == __LITTLE_ENDIAN
                /* We need to byte-swap slinear samples from network byte order */
        if (fr->af.datalen) {
 #if __BYTE_ORDER == __LITTLE_ENDIAN
                /* We need to byte-swap slinear samples from network byte order */
-               if (fr->af.subclass == AST_FORMAT_SLINEAR) {
+               if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass == AST_FORMAT_SLINEAR)) {
                        ast_swapcopy_samples(fr->af.data, f->data, fr->af.samples);
                } else
 #endif
                        ast_swapcopy_samples(fr->af.data, f->data, fr->af.samples);
                } else
 #endif