commit 9cf2fd9416bc0e3586e191fb732c7e7903bdce98
parent 8f2f072c167f518d25481826580217164516857e
Author: Olav Sørensen <olav.sorensen@live.no>
Date: Wed, 9 Feb 2022 15:27:22 +0100
Force stop WAV rendering if output file exceeds 2GB
Diffstat:
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/ft2_wav_renderer.c b/src/ft2_wav_renderer.c
@@ -309,6 +309,8 @@ static void updateVisuals(void)
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 @@ static int32_t SDLCALL renderWavThread(void *ptr)
}
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,9 +362,22 @@ static int32_t SDLCALL renderWavThread(void *ptr)
// 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)
{
@@ -385,10 +402,11 @@ static int32_t SDLCALL renderWavThread(void *ptr)
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)