mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
Rewrote parts of the test renderer to read the whole data from disk in one fread.
This commit is contained in:
parent
374be5256e
commit
9c7db45a46
@ -10,20 +10,24 @@ int main(int argc, char* argv[]) {
|
|||||||
int n;
|
int n;
|
||||||
int retval;
|
int retval;
|
||||||
char test_name[] = TEST_NAME;
|
char test_name[] = TEST_NAME;
|
||||||
|
long fsize;
|
||||||
|
long bufsize;
|
||||||
#ifndef GO4K_USE_16BIT_OUTPUT
|
#ifndef GO4K_USE_16BIT_OUTPUT
|
||||||
float* buf;
|
float* buf = NULL;
|
||||||
|
float* filebuf = NULL;
|
||||||
float v;
|
float v;
|
||||||
buf = (float*)malloc(test_max_samples * 2 * sizeof(float));
|
bufsize = test_max_samples * 2 * sizeof(float);
|
||||||
|
buf = (float*)malloc(bufsize);
|
||||||
#else
|
#else
|
||||||
short* buf;
|
short* buf = NULL;
|
||||||
|
short* filebuf = NULL;
|
||||||
short v;
|
short v;
|
||||||
buf = (short*)malloc(test_max_samples * 2 * sizeof(short));
|
bufsize = test_max_samples * 2 * sizeof(short);
|
||||||
|
buf = (short*)malloc(bufsize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
printf("Could not allocate buffer\n");
|
printf("Could not allocate buffer for 4klang rendering\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,35 +39,48 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
printf("No expected waveform found!\n");
|
printf("No expected waveform found!\n");
|
||||||
retval = 1;
|
goto fail;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 0;
|
fseek(f, 0, SEEK_END);
|
||||||
while (1) {
|
fsize = ftell(f);
|
||||||
fread((void*)(&v), sizeof(v), 1, f);
|
fseek(f, 0, SEEK_SET);
|
||||||
if (feof(f)) {
|
|
||||||
if (n == test_max_samples * 2) {
|
if (bufsize < fsize) {
|
||||||
retval = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("4klang rendered longer wave than expected\n");
|
|
||||||
retval = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (n >= test_max_samples * 2) {
|
|
||||||
printf("4klang rendered shorter wave than expected\n");
|
printf("4klang rendered shorter wave than expected\n");
|
||||||
retval = 1;
|
goto fail;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (buf[n] != v) {
|
|
||||||
|
if (bufsize > fsize) {
|
||||||
|
printf("4klang rendered longer wave than expected\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef GO4K_USE_16BIT_OUTPUT
|
||||||
|
filebuf = (float*)malloc(bufsize);
|
||||||
|
#else
|
||||||
|
filebuf = (short*)malloc(bufsize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (filebuf == NULL) {
|
||||||
|
printf("Could not allocate buffer for file contents\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
fread((void*)filebuf, test_max_samples * 2, sizeof(*filebuf), f);
|
||||||
|
|
||||||
|
for (n = 0; n < test_max_samples * 2; n++) {
|
||||||
|
if (buf[n] != filebuf[n]) {
|
||||||
printf("4klang rendered different wave than expected\n");
|
printf("4klang rendered different wave than expected\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
success:
|
||||||
|
retval = 0;
|
||||||
|
goto end;
|
||||||
|
fail:
|
||||||
retval = 1;
|
retval = 1;
|
||||||
break;
|
|
||||||
}
|
|
||||||
++n;
|
|
||||||
}
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
if (f != 0) {
|
if (f != 0) {
|
||||||
@ -80,5 +97,10 @@ end:
|
|||||||
free(buf);
|
free(buf);
|
||||||
buf = 0;
|
buf = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filebuf != 0) {
|
||||||
|
free(filebuf);
|
||||||
|
filebuf = 0;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user