Unified · Split
| @@ -309,6 +309,8 @@ static void updateVisuals(void) · 308 unmodified lines | ||
| 309 | 309 | |
| 310 | 310 | static int32_t SDLCALL renderWavThread(void *ptr) |
| 311 | 311 | { |
| 312 | + (void)ptr; | |
| 313 | + | |
| 312 | 314 | FILE *f = (FILE *)editor.wavRendererFileHandle; |
| 313 | 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 | 326 | uint32_t sampleCounter = 0; |
| 325 | − bool renderDone = false; | |
| 327 | + bool overflow = false, renderDone = false; | |
| 326 | 328 | uint8_t tickCounter = 4; |
| 327 | 329 | int64_t tickSampleCounter64 = 0; |
| 328 | 330 | |
| 331 | + uint64_t bytesInFile = sizeof (wavHeader_t); | |
| 332 | + | |
| 329 | 333 | editor.wavReachedEndFlag = false; |
| 330 | 334 | while (!renderDone) |
| 331 | 335 | { |
| @@ -358,9 +362,22 @@ static int32_t SDLCALL renderWavThread(void *ptr) · 26 unmodified lines | ||
| 358 | 362 | |
| 359 | 363 | // increase buffer pointer |
| 360 | 364 | if (WDBitDepth == 16) |
| 365 | + { | |
| 361 | 366 | ptr8 += remainingTick * sizeof (int16_t); |
| 367 | + bytesInFile += remainingTick * sizeof (int16_t); | |
| 368 | + } | |
| 362 | 369 | else |
| 370 | + { | |
| 363 | 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 | 382 | if (++tickCounter >= 4) |
| 366 | 383 | { |
| @@ -385,10 +402,11 @@ static int32_t SDLCALL renderWavThread(void *ptr) · 18 unmodified lines | ||
| 385 | 402 | dump_Close(f, sampleCounter); |
| 386 | 403 | resumeAudio(); |
| 387 | 404 | |
| 405 | + if (overflow) | |
| 406 | + okBoxThreadSafe(0, "System message", "Rendering stopped, file exceeded 2GB!"); | |
| 407 | + | |
| 388 | 408 | editor.diskOpReadOnOpen = true; |
| 389 | 409 | return true; |
| 390 | − | |
| 391 | − (void)ptr; | |
| 392 | 410 | } |
| 393 | 411 | |
| 394 | 412 | static void wavRender(bool checkOverwrite) |