History

Force stop WAV rendering if output file exceeds 2GB

Olav Sørensen committed 4 years ago

Commit 9cf2fd91 parent 8f2f0721 file · +21 −3Browse files

Unified · Split

src/ft2_wav_renderer.c+21−3
@@ -309,6 +309,8 @@ static void updateVisuals(void) · 308 unmodified lines
309 309
310static int32_t SDLCALL renderWavThread(void *ptr)310static int32_t SDLCALL renderWavThread(void *ptr)
311{311{
312 (void)ptr;
313
312 FILE *f = (FILE *)editor.wavRendererFileHandle;314 FILE *f = (FILE *)editor.wavRendererFileHandle;
313 fseek(f, sizeof (wavHeader_t), SEEK_SET);315 fseek(f, sizeof (wavHeader_t), SEEK_SET);
314 316
@@ -322,10 +324,12 @@ static int32_t SDLCALL renderWavThread(void *ptr) · 7 unmodified lines
322 }324 }
323 325
324 uint32_t sampleCounter = 0;326 uint32_t sampleCounter = 0;
325 bool renderDone = false;327 bool overflow = false, renderDone = false;
326 uint8_t tickCounter = 4;328 uint8_t tickCounter = 4;
327 int64_t tickSampleCounter64 = 0;329 int64_t tickSampleCounter64 = 0;
328 330
331 uint64_t bytesInFile = sizeof (wavHeader_t);
332
329 editor.wavReachedEndFlag = false;333 editor.wavReachedEndFlag = false;
330 while (!renderDone)334 while (!renderDone)
331 {335 {
@@ -358,9 +362,22 @@ static int32_t SDLCALL renderWavThread(void *ptr) · 26 unmodified lines
358 362
359 // increase buffer pointer363 // increase buffer pointer
360 if (WDBitDepth == 16)364 if (WDBitDepth == 16)
365 {
361 ptr8 += remainingTick * sizeof (int16_t);366 ptr8 += remainingTick * sizeof (int16_t);
367 bytesInFile += remainingTick * sizeof (int16_t);
368 }
362 else369 else
370 {
363 ptr8 += remainingTick * sizeof (float);371 ptr8 += remainingTick * sizeof (float);
372 bytesInFile += remainingTick * sizeof (float);
373 }
374
375 if (bytesInFile >= INT32_MAX)
376 {
377 renderDone = true;
378 overflow = true;
379 break;
380 }
364 381
365 if (++tickCounter >= 4)382 if (++tickCounter >= 4)
366 {383 {
@@ -385,10 +402,11 @@ static int32_t SDLCALL renderWavThread(void *ptr) · 18 unmodified lines
385 dump_Close(f, sampleCounter);402 dump_Close(f, sampleCounter);
386 resumeAudio();403 resumeAudio();
387 404
405 if (overflow)
406 okBoxThreadSafe(0, "System message", "Rendering stopped, file exceeded 2GB!");
407
388 editor.diskOpReadOnOpen = true;408 editor.diskOpReadOnOpen = true;
389 return true;409 return true;
390
391 (void)ptr;
392}410}
393 411
394static void wavRender(bool checkOverwrite)412static void wavRender(bool checkOverwrite)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t