Fixed crash in new audio channel conversion code

Each loop needs to be run num_frames times, and the source and destination pointers are incremented by the number of channels during the conversion.
This commit is contained in:
Sam Lantinga 2023-05-04 15:50:38 -07:00
parent c1dab7745a
commit 9b87de258f
2 changed files with 51 additions and 55 deletions

View file

@ -281,11 +281,7 @@ static void write_converter(const int fromchans, const int tochans)
printf(" * %d", tochans);
}
printf(";\n");
printf(" for (i = num_frames");
if (fromchans > 1) {
printf(" * %d", fromchans);
}
printf("; i; i--, ");
printf(" for (i = num_frames; i; i--, ");
if (fromchans == 1) {
printf("src--");
} else {
@ -342,7 +338,7 @@ static void write_converter(const int fromchans, const int tochans)
printf(" }\n");
} else {
printf(" for (i = num_frames * %d; i; i--, ", fromchans);
printf(" for (i = num_frames; i; i--, ");
if (fromchans == 1) {
printf("src++");
} else {