ref: 9cf2fd9416bc0e3586e191fb732c7e7903bdce98
parent: 8f2f072c167f518d25481826580217164516857e
author: Olav Sørensen <olav.sorensen@live.no>
date: Wed Feb 9 10:27:49 EST 2022
Force stop WAV rendering if output file exceeds 2GB
--- a/src/ft2_wav_renderer.c
+++ b/src/ft2_wav_renderer.c
@@ -309,6 +309,8 @@
static int32_t SDLCALL renderWavThread(void *ptr)
{
+ (void)ptr;
+
FILE *f = (FILE *)editor.wavRendererFileHandle;
fseek(f, sizeof (wavHeader_t), SEEK_SET);
@@ -322,10 +324,12 @@
}
uint32_t sampleCounter = 0;
- bool renderDone = false;
+ bool overflow = false, renderDone = false;
uint8_t tickCounter = 4;
int64_t tickSampleCounter64 = 0;
+ uint64_t bytesInFile = sizeof (wavHeader_t);
+
editor.wavReachedEndFlag = false;
while (!renderDone)
{
@@ -358,10 +362,23 @@
// increase buffer pointer
if (WDBitDepth == 16)
+ {
ptr8 += remainingTick * sizeof (int16_t);
+ bytesInFile += remainingTick * sizeof (int16_t);
+ }
else
+ {
ptr8 += remainingTick * sizeof (float);
+ bytesInFile += remainingTick * sizeof (float);
+ }
+ if (bytesInFile >= INT32_MAX)
+ {
+ renderDone = true;
+ overflow = true;
+ break;
+ }
+
if (++tickCounter >= 4)
{
tickCounter = 0;
@@ -385,10 +402,11 @@
dump_Close(f, sampleCounter);
resumeAudio();
+ if (overflow)
+ okBoxThreadSafe(0, "System message", "Rendering stopped, file exceeded 2GB!");
+
editor.diskOpReadOnOpen = true;
return true;
-
- (void)ptr;
}
static void wavRender(bool checkOverwrite)