# HG changeset patch # User Matti Hamalainen # Date 1425443514 -7200 # Node ID e466d10dae6d557ab63d6881ac5d06da727d4dd1 # Parent 0194c8a26aa881530ded51e5cba6419276d0adab 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. diff -r 0194c8a26aa8 -r e466d10dae6d minijss/jloadjss.c --- a/minijss/jloadjss.c Wed Mar 04 06:11:58 2015 +0200 +++ b/minijss/jloadjss.c Wed Mar 04 06:31:54 2015 +0200 @@ -485,6 +485,7 @@ if (inst && inst->hasData) { + int ret; size_t sz; // Calculate data size @@ -509,9 +510,15 @@ // Convert, if needed if (inst->flags & jsf16bit) - jssDecodeSample16(inst->data, inst->size, inst->convFlags); + ret = jssDecodeSample16(inst->data, inst->size, inst->convFlags); else - jssDecodeSample8(inst->data, inst->size, inst->convFlags); + ret = jssDecodeSample8(inst->data, inst->size, inst->convFlags); + + if (ret != DMERR_OK) + { + JSSERROR(ret, ret, + "Failed to decode sample data for #%d\n", index); + } } } #else diff -r 0194c8a26aa8 -r e466d10dae6d minijss/jssmod.c --- 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--) diff -r 0194c8a26aa8 -r e466d10dae6d minijss/jssmod.h --- a/minijss/jssmod.h Wed Mar 04 06:11:58 2015 +0200 +++ b/minijss/jssmod.h Wed Mar 04 06:31:54 2015 +0200 @@ -292,8 +292,8 @@ BOOL jssEncodeSample8(Uint8 *, const size_t, const int); BOOL jssEncodeSample16(Uint16 *, const size_t, const int); #endif -BOOL jssDecodeSample8(Uint8 *, const size_t, const int); -BOOL jssDecodeSample16(Uint16 *, const size_t, const int); +int jssDecodeSample8(Uint8 *, const size_t, const int); +int jssDecodeSample16(Uint16 *, const size_t, const int); int jssConvertModuleForPlaying(JSSModule *module); JSSModule * jssAllocateModule(void); int jssFreeModule(JSSModule *);