| 861 | // File rendering functions |
| 862 | |
| 863 | bool CSoundGen::RenderToFile(const fs::path &fname, std::shared_ptr<CWaveRenderer> pRender) // // // |
| 864 | { |
| 865 | // Called from main thread |
| 866 | ASSERT(GetCurrentThreadId() == FTEnv.GetMainApp()->m_nThreadID); |
| 867 | ASSERT(m_pDocument != NULL); |
| 868 | |
| 869 | if (!pRender) |
| 870 | return false; |
| 871 | |
| 872 | if (IsPlaying()) { |
| 873 | //HaltPlayer(); |
| 874 | m_bHaltRequest = true; |
| 875 | WaitForStop(); |
| 876 | } |
| 877 | |
| 878 | CSingleLock l(&m_csRenderer); l.Lock(); |
| 879 | m_pWaveRenderer = std::move(pRender); // // // |
| 880 | |
| 881 | ASSERT(!m_pRenderFile); |
| 882 | m_pRenderFile = std::make_shared<CSimpleFile>(fname, std::ios::out | std::ios::binary); // // // |
| 883 | if (m_pRenderFile) { |
| 884 | m_pWaveRenderer->SetOutputStream(std::make_unique<COutputWaveStream>(m_pRenderFile, CWaveFileFormat { |
| 885 | CWaveFileFormat::format_code::pcm, |
| 886 | 1, |
| 887 | static_cast<std::uint32_t>(FTEnv.GetSettings()->Sound.iSampleRate), |
| 888 | static_cast<std::uint16_t>(FTEnv.GetSettings()->Sound.iSampleSize), |
| 889 | })); |
| 890 | PostThreadMessageW(WM_USER_START_RENDER, 0, 0); |
| 891 | return true; |
| 892 | } |
| 893 | |
| 894 | StopPlayer(); |
| 895 | AfxMessageBox(IDS_FILE_OPEN_ERROR); |
| 896 | return false; |
| 897 | } |
| 898 | |
| 899 | // // // |
| 900 | void CSoundGen::StartRendering() { |
no test coverage detected