Mercurial > hg > dmlib
changeset 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 | 0194c8a26aa8 |
children | 725e7caa43a0 |
files | minijss/jloadjss.c minijss/jssmod.c minijss/jssmod.h |
diffstat | 3 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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--)
--- 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 *);