]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix some size_t\int warnings.
authorMichael Jerris <mike@jerris.com>
Fri, 30 Dec 2005 17:20:21 +0000 (17:20 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 30 Dec 2005 17:20:21 +0000 (17:20 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@245 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/switch_utils.c

index f682dd2d0fe21d538781fcd5044505d08f104470..cb9ac59eac6b0d51f8576220edf44701888c1873 100644 (file)
@@ -70,7 +70,7 @@ SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll,
 SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
 SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len);
 SWITCH_DECLARE(char *) switch_cut_path(char *in);
-SWITCH_DECLARE(int) switch_float_to_short(float *f, short *s, int len);
+SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len);
 SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len);
 SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len);
 SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len);
index bc9fdf4c9f182d59073ad81aaf6535d8a16d7fc1..68d55c00f2cff37aa6263a4bcd320282544658cc 100644 (file)
  *
  */
 #include <switch_utils.h>
-#define NORMFACT (float)0x8000\r
-#define MAXSAMPLE (float)0x7FFF\r
-#define MAXSAMPLEC (char)0x7F\r
-\r
-
-SWITCH_DECLARE(int) switch_float_to_short(float *f, short *s, int len)\r
-{\r
-       int i;\r
-       float ft;\r
-       for(i=0;i<len;i++) {\r
-               ft = f[i] * NORMFACT;\r
-               if(ft >= 0) {\r
-                       s[i] = (short)(ft+0.5);\r
-               } else {\r
-                       s[i] = (short)(ft-0.5);\r
-               }\r
-               if (s[i] > (short)MAXSAMPLE) s[i] = (short)MAXSAMPLE;\r
-               if (s[i] < (short)-MAXSAMPLE) s[i] = (short)-MAXSAMPLE;\r
-       }\r
-       return len;\r
-}\r
-\r
-SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len)\r
-{\r
-       int i;\r
-\r
-       if (len % 2) {\r
-               return(-1);\r
-       }\r
-\r
-       for(i=1;i<len;i+=2) {\r
-               f[(int)(i/2)] = (float)(((c[i])*0x100) + c[i-1]);\r
-               f[(int)(i/2)] /= NORMFACT;\r
-               if (f[(int)(i/2)] > MAXSAMPLE) f[(int)(i/2)] = MAXSAMPLE;\r
-               if (f[(int)(i/2)] < -MAXSAMPLE) f[(int)(i/2)] = -MAXSAMPLE;\r
-       }\r
-       return len/2;\r
-}\r
-
-SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len)\r
-{\r
-       int i;\r
-       float ft;\r
-       long l;\r
-       for(i=0;i<len;i++) {\r
-               ft = f[i] * NORMFACT;\r
-               if (ft >= 0) {\r
-                       l = (long)(ft+0.5);\r
-               } else {\r
-                       l = (long)(ft-0.5);\r
-               }\r
-               c[i*2] = (unsigned char)((l)&0xff);\r
-               c[i*2+1] = (unsigned char)(((l)>>8)&0xff);\r
-       }\r
-       return len*2;\r
-}\r
-\r
-SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len)\r
-{\r
-       int i;\r
-\r
-       for(i=0;i<len;i++) {\r
-               f[i] = (float)(s[i]) / NORMFACT;\r
-               //f[i] = (float) s[i];\r
-       }\r
-       return len;\r
-}\r
+#define NORMFACT (float)0x8000
+#define MAXSAMPLE (float)0x7FFF
+#define MAXSAMPLEC (char)0x7F
+
+
+SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len)
+{
+       size_t i;
+       float ft;
+       for(i=0;i<len;i++) {
+               ft = f[i] * NORMFACT;
+               if(ft >= 0) {
+                       s[i] = (short)(ft+0.5);
+               } else {
+                       s[i] = (short)(ft-0.5);
+               }
+               if (s[i] > (short)MAXSAMPLE) s[i] = (short)MAXSAMPLE;
+               if (s[i] < (short)-MAXSAMPLE) s[i] = (short)-MAXSAMPLE;
+       }
+       return len;
+}
+
+SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len)
+{
+       int i;
+
+       if (len % 2) {
+               return(-1);
+       }
+
+       for(i=1;i<len;i+=2) {
+               f[(int)(i/2)] = (float)(((c[i])*0x100) + c[i-1]);
+               f[(int)(i/2)] /= NORMFACT;
+               if (f[(int)(i/2)] > MAXSAMPLE) f[(int)(i/2)] = MAXSAMPLE;
+               if (f[(int)(i/2)] < -MAXSAMPLE) f[(int)(i/2)] = -MAXSAMPLE;
+       }
+       return len/2;
+}
+
+SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len)
+{
+       int i;
+       float ft;
+       long l;
+       for(i=0;i<len;i++) {
+               ft = f[i] * NORMFACT;
+               if (ft >= 0) {
+                       l = (long)(ft+0.5);
+               } else {
+                       l = (long)(ft-0.5);
+               }
+               c[i*2] = (unsigned char)((l)&0xff);
+               c[i*2+1] = (unsigned char)(((l)>>8)&0xff);
+       }
+       return len*2;
+}
+
+SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len)
+{
+       int i;
+
+       for(i=0;i<len;i++) {
+               f[i] = (float)(s[i]) / NORMFACT;
+               //f[i] = (float) s[i];
+       }
+       return len;
+}
 
 
 SWITCH_DECLARE(char *) switch_cut_path(char *in)