diff minijss/jssmod.c @ 1129:e466d10dae6d

Change API of jssDecodeSample{8,16}() functions to return dmlib error codes instead of plain boolean value. Change some of the relevant places to use this return value.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Mar 2015 06:31:54 +0200
parents e22d4ceb6414
children aa3738b121d1
line wrap: on
line diff
--- a/minijss/jssmod.c	Wed Mar 04 06:11:58 2015 +0200
+++ b/minijss/jssmod.c	Wed Mar 04 06:31:54 2015 +0200
@@ -126,7 +126,7 @@
 
 /* Decodes a given 8-bit sample
  */
-BOOL jssDecodeSample8(Uint8 * data, const size_t len, const int ops)
+int jssDecodeSample8(Uint8 * data, const size_t len, const int ops)
 {
     size_t count = len;
     Sint8 t, value = 0;
@@ -143,25 +143,27 @@
 
         *(data++) = t;
     }
-    return TRUE;
+    return DMERR_OK;
 }
 
 
 /* Decodes a given 16-bit sample
  */
-BOOL jssDecodeSample16(Uint16 * data, const size_t len, const int ops)
+int jssDecodeSample16(Uint16 * data, const size_t len, const int ops)
 {
     if (ops & jsampSplit)
     {
         size_t count, bufSize = len * sizeof(Uint16);
         Uint8 *bp1, *bp2;
         Sint16 *tmpBuf, *sdata;
+        int ret;
 
-        if (!jssDecodeSample8((Uint8 *) data, bufSize, ops))
-            return FALSE;
+        if ((ret = jssDecodeSample8((Uint8 *) data, bufSize, ops)) != DMERR_OK)
+            return ret;
 
-        tmpBuf = dmMalloc(bufSize);
-        if (tmpBuf == NULL) return FALSE;
+        if ((tmpBuf = dmMalloc(bufSize)) == NULL)
+            return DMERR_MALLOC;
+
         memcpy(tmpBuf, data, bufSize);
 
         sdata = (Sint16 *) data;
@@ -198,7 +200,7 @@
             *(sdata++) = t;
         }
     }
-    return TRUE;
+    return DMERR_OK;
 }
 
 
@@ -210,8 +212,7 @@
     Uint8 *in = (Uint8 *) src;
     Sint16 *out;
 
-    *dst = out = dmMalloc(sizeof(Sint16) * len);
-    if (out == NULL)
+    if ((*dst = out = dmMalloc(sizeof(Sint16) * len)) == NULL)
         return DMERR_MALLOC;
 
     while (count--)