Mercurial > hg > dmlib
comparison 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 |
comparison
equal
deleted
inserted
replaced
1971:c27f7cd25684 | 1972:cedb5ca1533b |
---|---|
450 { | 450 { |
451 JSSMODHeader jssH; | 451 JSSMODHeader jssH; |
452 const size_t patBufSize = 256*1024; // 256kB pattern buffer | 452 const size_t patBufSize = 256*1024; // 256kB pattern buffer |
453 Uint8 *patBuf; | 453 Uint8 *patBuf; |
454 size_t totalSize; | 454 size_t totalSize; |
455 int index; | 455 int index, res; |
456 | 456 |
457 // Check the module | 457 // Check the module |
458 if (module == NULL) | 458 if (module == NULL) |
459 { | 459 { |
460 JSSERROR(DMERR_NULLPTR, DMERR_NULLPTR, | 460 JSSERROR(DMERR_NULLPTR, DMERR_NULLPTR, |
703 { | 703 { |
704 size_t bsize = inst->size; | 704 size_t bsize = inst->size; |
705 if (inst->flags & jsf16bit) | 705 if (inst->flags & jsf16bit) |
706 { | 706 { |
707 bsize *= sizeof(Uint16); | 707 bsize *= sizeof(Uint16); |
708 jssEncodeSample16(inst->data, inst->size, flags16); | 708 res = jssEncodeSample16(inst->data, inst->size, flags16); |
709 } | 709 } |
710 else | 710 else |
711 { | 711 { |
712 bsize *= sizeof(Uint8); | 712 bsize *= sizeof(Uint8); |
713 jssEncodeSample8(inst->data, inst->size, flags8); | 713 res = jssEncodeSample8(inst->data, inst->size, flags8); |
714 } | |
715 | |
716 if (res != DMERR_OK) | |
717 { | |
718 JSSERROR(res, res, | |
719 "Error encoding sample for instrument #%d: %s\n", | |
720 index, dmErrorStr(res)); | |
714 } | 721 } |
715 | 722 |
716 if (!dm_fwrite_str(outFile, inst->data, bsize)) | 723 if (!dm_fwrite_str(outFile, inst->data, bsize)) |
717 { | 724 { |
718 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, | 725 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, |