diff tools/xm2jss.c @ 1972:cedb5ca1533b

Clean up the sample conversion code a bit. Improve error handling in xm2jss.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 30 Jun 2018 18:44:59 +0300
parents 93d1050eac99
children 0fddc51788de
line wrap: on
line diff
--- a/tools/xm2jss.c	Sat Jun 30 18:09:34 2018 +0300
+++ b/tools/xm2jss.c	Sat Jun 30 18:44:59 2018 +0300
@@ -452,7 +452,7 @@
     const size_t patBufSize = 256*1024; // 256kB pattern buffer
     Uint8 *patBuf;
     size_t totalSize;
-    int index;
+    int index, res;
 
     // Check the module
     if (module == NULL)
@@ -705,12 +705,19 @@
             if (inst->flags & jsf16bit)
             {
                 bsize *= sizeof(Uint16);
-                jssEncodeSample16(inst->data, inst->size, flags16);
+                res = jssEncodeSample16(inst->data, inst->size, flags16);
             }
             else
             {
                 bsize *= sizeof(Uint8);
-                jssEncodeSample8(inst->data, inst->size, flags8);
+                res = jssEncodeSample8(inst->data, inst->size, flags8);
+            }
+
+            if (res != DMERR_OK)
+            {
+                JSSERROR(res, res,
+                "Error encoding sample for instrument #%d: %s\n",
+                index, dmErrorStr(res));
             }
 
             if (!dm_fwrite_str(outFile, inst->data, bsize))