This commit is contained in:
Wiesław Šoltés 2018-02-25 20:12:10 +01:00
Родитель b3e227a9c5
Коммит 5221bcbc12
6 изменённых файлов: 357 добавлений и 372 удалений

Просмотреть файл

@ -4,21 +4,21 @@
namespace app
{
CEncWAVtoAC3App m_App;
CMainApp m_App;
BEGIN_MESSAGE_MAP(CEncWAVtoAC3App, CWinAppEx)
BEGIN_MESSAGE_MAP(CMainApp, CWinAppEx)
ON_COMMAND(ID_HELP, &CWinAppEx::OnHelp)
END_MESSAGE_MAP()
CEncWAVtoAC3App::CEncWAVtoAC3App()
CMainApp::CMainApp()
{
}
CEncWAVtoAC3App::~CEncWAVtoAC3App()
CMainApp::~CMainApp()
{
}
BOOL CEncWAVtoAC3App::InitInstance()
BOOL CMainApp::InitInstance()
{
this->m_Config.m_bIsPortable = PathFileExists((util::Utilities::GetExeFilePath() + FILENAME_PORTABLE).c_str()) == TRUE ? true : false;
@ -55,8 +55,24 @@ namespace app
try
{
DefaultConfig();
LoadConfig();
this->m_Config.m_szLangFileName = L"lang\\en-US.txt";
this->m_Config.m_nLangId = -1;
this->m_Config.m_bIsPortable = true;
this->m_Config.nCurrentPreset = 0;
this->m_Config.szOutputPath = L"";
this->m_Config.szOutputFile = L"";
this->m_Config.bMultiMonoInput = false;
this->m_Config.bDisableAllWarnings = false;
this->m_Config.bSaveConfig = true;
this->m_Config.nCurrentEngine = 0;
this->m_Config.SetEncoderOptions();
this->m_Config.LoadLanguagePath(this->m_Config.szLangPath);
if (this->m_Config.m_bIsPortable == true)
this->m_Config.LoadLanguages(util::Utilities::GetExeFilePath() + L"lang");
else
this->m_Config.LoadLanguages(util::Utilities::GetSettingsFilePath(L"", std::wstring(DIRECTORY_CONFIG) + L"\\lang"));
}
catch (...)
{
@ -98,7 +114,7 @@ namespace app
try
{
SaveConfig();
this->m_Config.SaveLanguagePath(this->m_Config.szLangPath);
}
catch (...)
{
@ -110,35 +126,4 @@ namespace app
return FALSE;
}
void CEncWAVtoAC3App::DefaultConfig()
{
this->m_Config.m_szLangFileName = L"lang\\en-US.txt";
this->m_Config.m_nLangId = -1;
this->m_Config.m_bIsPortable = true;
this->m_Config.nCurrentPreset = 0;
this->m_Config.szOutputPath = L"";
this->m_Config.szOutputFile = L"";
this->m_Config.bMultiMonoInput = false;
this->m_Config.bDisableAllWarnings = false;
this->m_Config.bSaveConfig = true;
this->m_Config.nCurrentEngine = 0;
}
void CEncWAVtoAC3App::LoadConfig()
{
this->m_Config.SetEncoderOptions();
this->m_Config.LoadLanguagePath(this->m_Config.szLangPath);
if (this->m_Config.m_bIsPortable == true)
this->m_Config.LoadLanguages(util::Utilities::GetExeFilePath() + L"lang");
else
this->m_Config.LoadLanguages(util::Utilities::GetSettingsFilePath(L"", std::wstring(DIRECTORY_CONFIG) + L"\\lang"));
}
void CEncWAVtoAC3App::SaveConfig()
{
this->m_Config.SaveLanguagePath(this->m_Config.szLangPath);
}
}

Просмотреть файл

@ -25,21 +25,17 @@
namespace app
{
class CEncWAVtoAC3App : public CWinAppEx
class CMainApp : public CWinAppEx
{
public:
CEncWAVtoAC3App();
virtual ~CEncWAVtoAC3App();
CMainApp();
virtual ~CMainApp();
public:
virtual BOOL InitInstance();
DECLARE_MESSAGE_MAP()
public:
config::CConfiguration m_Config;
public:
void DefaultConfig();
void LoadConfig();
void SaveConfig();
};
extern CEncWAVtoAC3App m_App;
extern CMainApp m_App;
}

Просмотреть файл

@ -106,7 +106,7 @@ int wmain(int argc, wchar_t *argv[])
}
}
if (app.Init() == false)
if (app.LoadConfiguration() == false)
{
app.CloseLog();
return -1;

Просмотреть файл

@ -105,6 +105,41 @@ class MainApp
{
public:
config::CConfiguration m_Config;
public:
void OpenLog()
{
this->m_Config.Log = std::make_unique<logger::ConsoleLog>();
this->m_Config.Log->Open();
this->m_Config.Log->Log(L"[Info] Program started: CLI");
}
void CloseLog()
{
this->m_Config.Log->Log(L"[Info] Program exited: CLI");
this->m_Config.Log->Close();
}
void DefaultConfig()
{
this->m_Config.m_bIsPortable = true;
this->m_Config.nCurrentPreset = 0;
this->m_Config.szOutputPath = L"";
this->m_Config.szOutputFile = L"";
this->m_Config.bUseOutputPath = false;
this->m_Config.bMultiMonoInput = false;
this->m_Config.bDisableAllWarnings = true;
this->m_Config.bSaveConfig = false;
this->m_Config.nCurrentEngine = 0;
this->m_Config.SetEncoderOptions();
this->m_Config.InitDefaultPreset();
this->m_Config.InitDefaultEngine();
this->m_Config.m_Presets.emplace_back(this->m_Config.m_DefaultPreset);
this->m_Config.m_Engines.emplace_back(this->m_Config.m_DefaultEngine);
this->m_Config.szLogPath = L"";
this->m_Config.szConfigPath = L"";
this->m_Config.szLangPath = L"";
this->m_Config.szPresetsPath = L"";
this->m_Config.szEnginesPath = L"";
this->m_Config.szFilesPath = L"";
}
public:
bool GetAvisynthFileInfo(std::wstring szFileName, AvsAudioInfo *pInfoAVS)
{
@ -189,43 +224,6 @@ public:
}
return true;
}
public:
void OpenLog()
{
this->m_Config.Log = std::make_unique<logger::ConsoleLog>();
this->m_Config.Log->Open();
this->m_Config.Log->Log(L"[Info] Program started: CLI");
}
void CloseLog()
{
this->m_Config.Log->Log(L"[Info] Program exited: CLI");
this->m_Config.Log->Close();
}
public:
void DefaultConfig()
{
this->m_Config.m_bIsPortable = true;
this->m_Config.nCurrentPreset = 0;
this->m_Config.szOutputPath = L"";
this->m_Config.szOutputFile = L"";
this->m_Config.bUseOutputPath = false;
this->m_Config.bMultiMonoInput = false;
this->m_Config.bDisableAllWarnings = true;
this->m_Config.bSaveConfig = false;
this->m_Config.nCurrentEngine = 0;
this->m_Config.SetEncoderOptions();
this->m_Config.InitDefaultPreset();
this->m_Config.InitDefaultEngine();
this->m_Config.m_Presets.emplace_back(this->m_Config.m_DefaultPreset);
this->m_Config.m_Engines.emplace_back(this->m_Config.m_DefaultEngine);
this->m_Config.szLogPath = L"";
this->m_Config.szConfigPath = L"";
this->m_Config.szLangPath = L"";
this->m_Config.szPresetsPath = L"";
this->m_Config.szEnginesPath = L"";
this->m_Config.szFilesPath = L"";
}
public:
bool LoadPresets(const std::wstring &szFileName)
{
std::vector<config::CPreset> presets;
@ -258,8 +256,7 @@ public:
}
return false;
}
public:
bool Init()
bool LoadConfiguration()
{
if (!this->m_Config.szPresetsPath.empty() && this->LoadPresets(this->m_Config.szPresetsPath))
{

Просмотреть файл

@ -1039,6 +1039,119 @@ namespace dialogs
}
}
void CMainDlg::SearchFolderForFiles(const std::wstring szPath, const bool bRecurse)
{
try
{
std::vector<std::wstring> files;
if (util::Utilities::FindFiles(szPath, files, bRecurse) == true)
{
this->AddFiles(files);
this->RedrawFiles();
}
}
catch (...)
{
this->pConfig->Log->Log(L"[Error] Exception thrown when searching for files.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x0020702A).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
}
}
bool CMainDlg::GetAvisynthFileInfo(const std::wstring szFileName, AvsAudioInfo *pInfoAVS)
{
if (pInfoAVS == nullptr)
return false;
memset(pInfoAVS, 0, sizeof(AvsAudioInfo));
CAvs2Raw decoderAVS;
std::string szInputFileAVS = util::StringHelper::Convert(szFileName);
if (decoderAVS.OpenAvisynth(szInputFileAVS.c_str()) == false)
{
this->pConfig->Log->Log(L"[Error] Failed to initialize Avisynth.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207022).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
return false;
}
else
{
(*pInfoAVS) = decoderAVS.GetInputInfo();
decoderAVS.CloseAvisynth();
return true;
}
}
ULONGLONG CMainDlg::GetFileSize(const std::wstring& szPath)
{
std::wstring szExt = util::Utilities::GetFileExtension(szPath);
if (util::StringHelper::TowLower(szExt) == L"avs")
{
AvsAudioInfo infoAVS;
memset(&infoAVS, 0, sizeof(AvsAudioInfo));
if (GetAvisynthFileInfo(szPath, &infoAVS) == true)
{
ULONGLONG nFileSize = infoAVS.nAudioSamples * infoAVS.nBytesPerChannelSample * infoAVS.nAudioChannels;
return nFileSize;
}
}
else
{
ULONGLONG nFileSize = util::Utilities::GetFileSize64(szPath);
return nFileSize;
}
return 0;
}
bool CMainDlg::AddFile(const std::wstring& szPath)
{
std::wstring szExt = util::Utilities::GetFileExtension(szPath);
if (this->pConfig->IsSupportedInputExt(szExt) == true)
{
ULONGLONG nSize = this->GetFileSize(szPath);
config::CFile file{ szPath, nSize };
this->pConfig->m_Files.emplace_back(file);
return true;
}
return false;
}
bool CMainDlg::AddPath(const std::wstring& pattern)
{
std::vector<std::wstring> files = util::Utilities::FindFiles(pattern);
if (files.size() > 0)
{
for (auto& file : files)
this->AddFile(file);
return true;
}
return false;
}
bool CMainDlg::AddFiles(const std::vector<std::wstring>& files)
{
for (auto& file : files)
{
if (file.find('*', 0) != std::wstring::npos)
{
this->AddPath(file);
}
else
{
if (this->AddFile(file) == false)
{
this->pConfig->Log->Log(L"[Error] Not supported input file: " + file);
return false;
}
}
}
return true;
}
bool CMainDlg::LoadPresets(const std::wstring& szFileName)
{
std::vector<config::CPreset> presets;
@ -1188,117 +1301,196 @@ namespace dialogs
this->pConfig->Log->Log(L"[Error] Failed to save program config: " + this->pConfig->szConfigPath);
}
void CMainDlg::SearchFolderForFiles(const std::wstring szPath, const bool bRecurse)
void CMainDlg::Encode()
{
try
static bool bWorking = false;
if (bWorking == true)
return;
bWorking = true;
int nItemsCount = this->pConfig->m_Files.size();
if (nItemsCount <= 0)
{
std::vector<std::wstring> files;
if (util::Utilities::FindFiles(szPath, files, bRecurse) == true)
{
this->AddFiles(files);
this->RedrawFiles();
}
}
catch (...)
{
this->pConfig->Log->Log(L"[Error] Exception thrown when searching for files.");
this->pConfig->Log->Log(L"[Error] Add at least one file to the file list.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x0020702A).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
this->MessageBox(this->pConfig->GetString(0x00207011).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
bWorking = false;
return;
}
}
bool CMainDlg::GetAvisynthFileInfo(const std::wstring szFileName, AvsAudioInfo *pInfoAVS)
{
if (pInfoAVS == nullptr)
return false;
memset(pInfoAVS, 0, sizeof(AvsAudioInfo));
CAvs2Raw decoderAVS;
std::string szInputFileAVS = util::StringHelper::Convert(szFileName);
if (decoderAVS.OpenAvisynth(szInputFileAVS.c_str()) == false)
if ((this->pConfig->bMultiMonoInput == true) && (nItemsCount < 1 || nItemsCount > 6))
{
this->pConfig->Log->Log(L"[Error] Failed to initialize Avisynth.");
this->pConfig->Log->Log(L"[Error] Supported are minimum 1 and maximum 6 mono input files.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207022).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
this->MessageBox(this->pConfig->GetString(0x00207012).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
return false;
bWorking = false;
return;
}
if (this->pConfig->m_bIsPortable == true)
::SetCurrentDirectory(util::Utilities::GetExeFilePath().c_str());
else
{
(*pInfoAVS) = decoderAVS.GetInputInfo();
decoderAVS.CloseAvisynth();
return true;
}
}
::SetCurrentDirectory(util::Utilities::GetSettingsFilePath(_T(""), DIRECTORY_CONFIG).c_str());
ULONGLONG CMainDlg::GetFileSize(const std::wstring& szPath)
{
std::wstring szExt = util::Utilities::GetFileExtension(szPath);
if (util::StringHelper::TowLower(szExt) == L"avs")
CWorkDlg dlg;
dlg.pConfig = this->pConfig;
dlg.pWorkerContext = std::make_unique<CWorkDlgWorkerContext>(&dlg);
dlg.pWorkerContext->bTerminate = false;
dlg.pWorkerContext->bCanUpdateWindow = true;
dlg.pWorkerContext->nEncodedFiles = 0;
dlg.pWorkerContext->m_ElapsedTimeFile = 0;
dlg.pWorkerContext->m_ElapsedTimeTotal = 0;
dlg.pWorkerContext->nTotalSize = 0;
for (int i = 0; i < nItemsCount; i++)
{
AvsAudioInfo infoAVS;
memset(&infoAVS, 0, sizeof(AvsAudioInfo));
if (GetAvisynthFileInfo(szPath, &infoAVS) == true)
config::CFile& file = this->pConfig->m_Files[i];
std::wstring szExt = util::Utilities::GetFileExtension(file.szPath);
if (util::StringHelper::TowLower(szExt) == L"avs")
{
ULONGLONG nFileSize = infoAVS.nAudioSamples * infoAVS.nBytesPerChannelSample * infoAVS.nAudioChannels;
return nFileSize;
}
}
else
{
ULONGLONG nFileSize = util::Utilities::GetFileSize64(szPath);
return nFileSize;
}
return 0;
}
bool CMainDlg::AddFile(const std::wstring& szPath)
{
std::wstring szExt = util::Utilities::GetFileExtension(szPath);
if (this->pConfig->IsSupportedInputExt(szExt) == true)
{
ULONGLONG nSize = this->GetFileSize(szPath);
config::CFile file { szPath, nSize };
this->pConfig->m_Files.emplace_back(file);
return true;
}
return false;
}
bool CMainDlg::AddPath(const std::wstring& pattern)
{
std::vector<std::wstring> files = util::Utilities::FindFiles(pattern);
if (files.size() > 0)
{
for (auto& file : files)
this->AddFile(file);
return true;
}
return false;
}
bool CMainDlg::AddFiles(const std::vector<std::wstring>& files)
{
for (auto& file : files)
{
if (file.find('*', 0) != std::wstring::npos)
{
this->AddPath(file);
}
else
{
if (this->AddFile(file) == false)
if (this->pConfig->bMultiMonoInput == true)
{
this->pConfig->Log->Log(L"[Error] Not supported input file: " + file);
return false;
this->pConfig->Log->Log(L"[Error] Disable 'Multiple mono input' mode in order to use Avisynth scripts.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207014).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
bWorking = false;
return;
}
}
file.bStatus = false;
dlg.pWorkerContext->nTotalSize += file.nSize;
}
CString szOutputPath;
this->m_EdtOutPath.GetWindowText(szOutputPath);
this->pConfig->szOutputPath = szOutputPath;
this->pConfig->bUseOutputPath = false;
int nLen = this->pConfig->szOutputPath.length();
if (nLen < 3)
{
this->pConfig->Log->Log(L"[Error] Invalid output path.");
{
this->MessageBox(this->pConfig->GetString(0x00207015).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
std::wstring szExt = this->pConfig->szOutputPath.substr(this->pConfig->szOutputPath.length() - 4, 4);
if (this->pConfig->bMultiMonoInput == true)
{
if (this->pConfig->szOutputPath != this->pConfig->GetString(0x00207005).c_str())
{
if ((nLen < 4) || (!util::StringHelper::CompareNoCase(szExt, L".ac3")))
{
this->pConfig->Log->Log(L"[Error] Invalid output file.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207016).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
}
}
return true;
if ((!this->pConfig->szOutputPath.empty()) &&
((this->pConfig->szOutputPath != this->pConfig->GetString(0x00207004).c_str() && this->pConfig->bMultiMonoInput == false) ||
(this->pConfig->szOutputPath != this->pConfig->GetString(0x00207005).c_str() && this->pConfig->bMultiMonoInput == true)))
{
if (this->pConfig->bMultiMonoInput == false)
{
if (util::Utilities::MakeFullPath(this->pConfig->szOutputPath) == false)
{
this->pConfig->Log->Log(L"[Error] Failed to create output path.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207017).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
}
else
{
std::wstring szFile = util::Utilities::GetFileName(this->pConfig->szOutputPath);
std::wstring szOutputPath = this->pConfig->szOutputPath.substr(0, this->pConfig->szOutputPath.length() - szFile.length());
if (util::Utilities::MakeFullPath(szOutputPath) == false)
{
this->pConfig->Log->Log(L"[Error] Failed to create output path: " + szOutputPath);
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207017).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
}
this->pConfig->bUseOutputPath = true;
}
util::CTimeCount countTime;
countTime.Start();
dlg.DoModal();
countTime.Stop();
std::wstring szElapsedFormatted = countTime.Format(countTime.ElapsedTime());
double szElapsedSeconds = countTime.ElapsedTime().count() / 1000.0f;
for (int i = (int)this->pConfig->m_Files.size() - 1; i >= 0; i--)
{
if (this->pConfig->m_Files[i].bStatus == true)
this->pConfig->m_Files.erase(this->pConfig->m_Files.begin() + i);
}
this->RedrawFiles();
CString szStatus;
if (dlg.pWorkerContext->nEncodedFiles <= 0)
{
szStatus = _T("");
this->pConfig->Log->Log(L"[Error] Failed to encode all files.");
}
else
{
if (this->pConfig->bMultiMonoInput == true)
{
szStatus.Format(this->pConfig->GetString(0x00207018).c_str(),
dlg.pWorkerContext->nEncodedFiles,
szElapsedFormatted.c_str(),
szElapsedSeconds);
this->pConfig->Log->Log(
L"[Info] Encoded " + std::to_wstring(dlg.pWorkerContext->nEncodedFiles) +
L" mono files in " + szElapsedFormatted + L" (" + std::to_wstring(szElapsedSeconds) + L"s).");
}
else
{
szStatus.Format(this->pConfig->GetString(0x00207019).c_str(),
dlg.pWorkerContext->nEncodedFiles,
dlg.pWorkerContext->nEncodedFiles == 1 ? _T("") :
this->pConfig->GetString(0x0020701A).c_str(),
szElapsedFormatted.c_str(),
szElapsedSeconds);
this->pConfig->Log->Log(
L"[Info] Encoded " + std::to_wstring(dlg.pWorkerContext->nEncodedFiles) +
L" file" + ((dlg.pWorkerContext->nEncodedFiles == 1) ? L"" : L"s") +
L" in " + szElapsedFormatted + L" (" + std::to_wstring(szElapsedSeconds) + L"s).");
}
}
this->m_StatusBar.SetText(szStatus, 0, 0);
bWorking = false;
}
void CMainDlg::OnPaint()
@ -2067,194 +2259,7 @@ namespace dialogs
void CMainDlg::OnBnClickedButtonEncode()
{
static bool bWorking = false;
if (bWorking == true)
return;
bWorking = true;
int nItemsCount = this->pConfig->m_Files.size();
if (nItemsCount <= 0)
{
this->pConfig->Log->Log(L"[Error] Add at least one file to the file list.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207011).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
bWorking = false;
return;
}
if ((this->pConfig->bMultiMonoInput == true) && (nItemsCount < 1 || nItemsCount > 6))
{
this->pConfig->Log->Log(L"[Error] Supported are minimum 1 and maximum 6 mono input files.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207012).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
bWorking = false;
return;
}
if (this->pConfig->m_bIsPortable == true)
::SetCurrentDirectory(util::Utilities::GetExeFilePath().c_str());
else
::SetCurrentDirectory(util::Utilities::GetSettingsFilePath(_T(""), DIRECTORY_CONFIG).c_str());
CWorkDlg dlg;
dlg.pConfig = this->pConfig;
dlg.pWorkerContext = std::make_unique<CWorkDlgWorkerContext>(&dlg);
dlg.pWorkerContext->bTerminate = false;
dlg.pWorkerContext->bCanUpdateWindow = true;
dlg.pWorkerContext->nEncodedFiles = 0;
dlg.pWorkerContext->m_ElapsedTimeFile = 0;
dlg.pWorkerContext->m_ElapsedTimeTotal = 0;
dlg.pWorkerContext->nTotalSize = 0;
for (int i = 0; i < nItemsCount; i++)
{
config::CFile& file = this->pConfig->m_Files[i];
std::wstring szExt = util::Utilities::GetFileExtension(file.szPath);
if (util::StringHelper::TowLower(szExt) == L"avs")
{
if (this->pConfig->bMultiMonoInput == true)
{
this->pConfig->Log->Log(L"[Error] Disable 'Multiple mono input' mode in order to use Avisynth scripts.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207014).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_ICONERROR | MB_OK);
}
bWorking = false;
return;
}
}
file.bStatus = false;
dlg.pWorkerContext->nTotalSize += file.nSize;
}
CString szOutputPath;
this->m_EdtOutPath.GetWindowText(szOutputPath);
this->pConfig->szOutputPath = szOutputPath;
this->pConfig->bUseOutputPath = false;
int nLen = this->pConfig->szOutputPath.length();
if (nLen < 3)
{
this->pConfig->Log->Log(L"[Error] Invalid output path.");
{
this->MessageBox(this->pConfig->GetString(0x00207015).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
std::wstring szExt = this->pConfig->szOutputPath.substr(this->pConfig->szOutputPath.length() - 4, 4);
if (this->pConfig->bMultiMonoInput == true)
{
if (this->pConfig->szOutputPath != this->pConfig->GetString(0x00207005).c_str())
{
if ((nLen < 4) || (!util::StringHelper::CompareNoCase(szExt, L".ac3")))
{
this->pConfig->Log->Log(L"[Error] Invalid output file.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207016).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
}
}
if ((!this->pConfig->szOutputPath.empty()) &&
((this->pConfig->szOutputPath != this->pConfig->GetString(0x00207004).c_str() && this->pConfig->bMultiMonoInput == false) ||
(this->pConfig->szOutputPath != this->pConfig->GetString(0x00207005).c_str() && this->pConfig->bMultiMonoInput == true)))
{
if (this->pConfig->bMultiMonoInput == false)
{
if (util::Utilities::MakeFullPath(this->pConfig->szOutputPath) == false)
{
this->pConfig->Log->Log(L"[Error] Failed to create output path.");
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207017).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
}
else
{
std::wstring szFile = util::Utilities::GetFileName(this->pConfig->szOutputPath);
std::wstring szOutputPath = this->pConfig->szOutputPath.substr(0, this->pConfig->szOutputPath.length() - szFile.length());
if (util::Utilities::MakeFullPath(szOutputPath) == false)
{
this->pConfig->Log->Log(L"[Error] Failed to create output path: " + szOutputPath);
if (this->pConfig->bDisableAllWarnings == false)
{
this->MessageBox(this->pConfig->GetString(0x00207017).c_str(), this->pConfig->GetString(0x00207010).c_str(), MB_OK | MB_ICONERROR);
}
bWorking = false;
return;
}
}
this->pConfig->bUseOutputPath = true;
}
util::CTimeCount countTime;
countTime.Start();
dlg.DoModal();
countTime.Stop();
std::wstring szElapsedFormatted = countTime.Format(countTime.ElapsedTime());
double szElapsedSeconds = countTime.ElapsedTime().count() / 1000.0f;
for (int i = (int)this->pConfig->m_Files.size() - 1; i >= 0; i--)
{
if (this->pConfig->m_Files[i].bStatus == true)
this->pConfig->m_Files.erase(this->pConfig->m_Files.begin() + i);
}
this->RedrawFiles();
CString szStatus;
if (dlg.pWorkerContext->nEncodedFiles <= 0)
{
szStatus = _T("");
this->pConfig->Log->Log(L"[Error] Failed to encode all files.");
}
else
{
if (this->pConfig->bMultiMonoInput == true)
{
szStatus.Format(this->pConfig->GetString(0x00207018).c_str(),
dlg.pWorkerContext->nEncodedFiles,
szElapsedFormatted.c_str(),
szElapsedSeconds);
this->pConfig->Log->Log(
L"[Info] Encoded " + std::to_wstring(dlg.pWorkerContext->nEncodedFiles) +
L" mono files in " + szElapsedFormatted + L" (" + std::to_wstring(szElapsedSeconds) + L"s).");
}
else
{
szStatus.Format(this->pConfig->GetString(0x00207019).c_str(),
dlg.pWorkerContext->nEncodedFiles,
dlg.pWorkerContext->nEncodedFiles == 1 ? _T("") :
this->pConfig->GetString(0x0020701A).c_str(),
szElapsedFormatted.c_str(),
szElapsedSeconds);
this->pConfig->Log->Log(
L"[Info] Encoded " + std::to_wstring(dlg.pWorkerContext->nEncodedFiles) +
L" file" + ((dlg.pWorkerContext->nEncodedFiles == 1) ? L"" : L"s") +
L" in " + szElapsedFormatted + L" (" + std::to_wstring(szElapsedSeconds) + L"s).");
}
}
this->m_StatusBar.SetText(szStatus, 0, 0);
bWorking = false;
this->Encode();
}
void CMainDlg::OnBnClickedCheckSimdMmx()

Просмотреть файл

@ -111,6 +111,13 @@ namespace dialogs
void ApplyPresetToDlg(const config::CPreset &preset);
void ApplyEngineToDlg(const config::CEngine &engine);
void ApplyConfigToDlg(const std::vector<config::Entry>& entries);
void SearchFolderForFiles(const std::wstring szFile, const bool bRecurse);
public:
bool GetAvisynthFileInfo(const std::wstring szFileName, AvsAudioInfo *pInfoAVS);
ULONGLONG GetFileSize(const std::wstring& szPath);
bool AddFile(const std::wstring& szPath);
bool AddPath(const std::wstring& pattern);
bool AddFiles(const std::vector<std::wstring>& files);
bool LoadPresets(const std::wstring& szFileName);
bool SavePresets(const std::wstring& szFileName);
bool LoadEngines(const std::wstring& szFileName);
@ -121,12 +128,7 @@ namespace dialogs
bool SaveConfig(const std::wstring& szFileName);
void LoadConfiguration();
void SaveConfiguration();
void SearchFolderForFiles(const std::wstring szFile, const bool bRecurse);
bool GetAvisynthFileInfo(const std::wstring szFileName, AvsAudioInfo *pInfoAVS);
ULONGLONG GetFileSize(const std::wstring& szPath);
bool AddFile(const std::wstring& szPath);
bool AddPath(const std::wstring& pattern);
bool AddFiles(const std::vector<std::wstring>& files);
void Encode();
protected:
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();