From 3f9096fdd0dc02dbf0d80738b65200d6508d2a9e Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Wed, 25 Mar 2020 14:08:26 +0300 Subject: [PATCH] A true fix of the VOC_EXTENDED channels number reading #35 Regarding to this specification https://wiki.multimedia.cx/index.php?title=Creative_Voice#Block_type_0x08:_Extra_info A count of channels stored in the file is a value with 1 subtracted --- src/codecs/load_voc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/codecs/load_voc.c b/src/codecs/load_voc.c index 4067abc9..1c76bca3 100644 --- a/src/codecs/load_voc.c +++ b/src/codecs/load_voc.c @@ -287,7 +287,13 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec) if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) return 0; - spec->channels = uc ? 2 /* Stereo */: 1; /* Mono */ + if (uc == 255) + { + SDL_SetError("VOC Extended has an invalid channels number"); + return 0; + } + + spec->channels = uc + 1; /* 0 - Mono, 1 - Stereo*/ /* Needed number of channels before finishing compute for rate */