|
1 | 1 | /* |
2 | | - Copyright (C) 2006-2024 DeSmuME team |
| 2 | + Copyright (C) 2006-2025 DeSmuME team |
3 | 3 |
|
4 | 4 | This file is free software: you can redistribute it and/or modify |
5 | 5 | it under the terms of the GNU General Public License as published by |
@@ -517,51 +517,13 @@ HRESULT AVIFileStream::WriteAllFrames() |
517 | 517 |
|
518 | 518 | NDSCaptureObject::NDSCaptureObject() |
519 | 519 | { |
520 | | - // Create the format structs. |
521 | | - memset(&_bmpFormat, 0, sizeof(BITMAPINFOHEADER)); |
522 | | - _bmpFormat.biSize = 0x28; |
523 | | - _bmpFormat.biPlanes = 1; |
524 | | - _bmpFormat.biBitCount = 24; |
525 | | - |
526 | | - memset(&_wavFormat, 0, sizeof(WAVEFORMATEX)); |
527 | | - |
528 | | - _pendingVideoBuffer = NULL; |
529 | | - _pendingAudioBuffer = NULL; |
530 | | - _pendingAudioWriteSize = NULL; |
531 | | - _pendingBufferCount = 0; |
532 | | - _currentBufferIndex = 0; |
533 | | - |
534 | | - // Create the colorspace conversion threads. |
535 | | - _numThreads = CommonSettings.num_cores; |
536 | | - |
537 | | - if (_numThreads > MAX_CONVERT_THREADS) |
538 | | - { |
539 | | - _numThreads = MAX_CONVERT_THREADS; |
540 | | - } |
541 | | - else if (_numThreads < 2) |
542 | | - { |
543 | | - _numThreads = 0; |
544 | | - } |
545 | | - |
546 | | - for (size_t i = 0; i < _numThreads; i++) |
547 | | - { |
548 | | - memset(&_convertParam[i], 0, sizeof(VideoConvertParam)); |
549 | | - _convertParam[i].captureObj = this; |
550 | | - |
551 | | - _convertThread[i] = new Task(); |
552 | | - _convertThread[i]->start(false); |
553 | | - } |
554 | | - |
555 | | - // Generate the AVI file streams. |
556 | | - _fs = new AVIFileStream; |
557 | | - |
558 | | - _fileWriteThread = new Task(); |
559 | | - _fileWriteThread->start(false); |
| 520 | + __InstanceInit(); |
560 | 521 | } |
561 | 522 |
|
562 | 523 | NDSCaptureObject::NDSCaptureObject(size_t frameWidth, size_t frameHeight, const WAVEFORMATEX *wfex) |
563 | | - : NDSCaptureObject() |
564 | 524 | { |
| 525 | + __InstanceInit(); |
| 526 | + |
565 | 527 | _bmpFormat.biWidth = frameWidth; |
566 | 528 | _bmpFormat.biHeight = frameHeight * 2; |
567 | 529 | _bmpFormat.biSizeImage = _bmpFormat.biWidth * _bmpFormat.biHeight * 3; |
@@ -623,6 +585,50 @@ NDSCaptureObject::NDSCaptureObject(size_t frameWidth, size_t frameHeight, const |
623 | 585 | } |
624 | 586 | } |
625 | 587 |
|
| 588 | +void NDSCaptureObject::__InstanceInit() |
| 589 | +{ |
| 590 | + // Create the format structs. |
| 591 | + memset(&_bmpFormat, 0, sizeof(BITMAPINFOHEADER)); |
| 592 | + _bmpFormat.biSize = 0x28; |
| 593 | + _bmpFormat.biPlanes = 1; |
| 594 | + _bmpFormat.biBitCount = 24; |
| 595 | + |
| 596 | + memset(&_wavFormat, 0, sizeof(WAVEFORMATEX)); |
| 597 | + |
| 598 | + _pendingVideoBuffer = NULL; |
| 599 | + _pendingAudioBuffer = NULL; |
| 600 | + _pendingAudioWriteSize = NULL; |
| 601 | + _pendingBufferCount = 0; |
| 602 | + _currentBufferIndex = 0; |
| 603 | + |
| 604 | + // Create the colorspace conversion threads. |
| 605 | + _numThreads = CommonSettings.num_cores; |
| 606 | + |
| 607 | + if (_numThreads > MAX_CONVERT_THREADS) |
| 608 | + { |
| 609 | + _numThreads = MAX_CONVERT_THREADS; |
| 610 | + } |
| 611 | + else if (_numThreads < 2) |
| 612 | + { |
| 613 | + _numThreads = 0; |
| 614 | + } |
| 615 | + |
| 616 | + for (size_t i = 0; i < _numThreads; i++) |
| 617 | + { |
| 618 | + memset(&_convertParam[i], 0, sizeof(VideoConvertParam)); |
| 619 | + _convertParam[i].captureObj = this; |
| 620 | + |
| 621 | + _convertThread[i] = new Task(); |
| 622 | + _convertThread[i]->start(false); |
| 623 | + } |
| 624 | + |
| 625 | + // Generate the AVI file streams. |
| 626 | + _fs = new AVIFileStream; |
| 627 | + |
| 628 | + _fileWriteThread = new Task(); |
| 629 | + _fileWriteThread->start(false); |
| 630 | +} |
| 631 | + |
626 | 632 | NDSCaptureObject::~NDSCaptureObject() |
627 | 633 | { |
628 | 634 | this->_fileWriteThread->finish(); |
|
0 commit comments