Cache ffmpeg/transcoder paths

This significantly speeds up loading export formats that use ffmpeg.

A single call to ::transcoder_exe() took 300-400ms on Windows.
With multiple formats using an external transcoder, showing the
export dialog could take to 2-3 sec.
This commit is contained in:
Robin Gareus 2020-12-22 22:21:48 +01:00
parent ce07765347
commit 9ba8166ae8
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -144,6 +144,16 @@ ArdourVideoToolPaths::xjadeo_exe (std::string &xjadeo_exe)
bool bool
ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe) ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe)
{ {
static bool _cached = false;
static std::string _ffmpeg_exe;
static std::string _ffprobe_exe;
if (_cached) {
ffmpeg_exe = _ffmpeg_exe;
ffprobe_exe = _ffprobe_exe;
return true;
}
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
std::string reg; std::string reg;
std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES); std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
@ -201,6 +211,11 @@ ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffpr
if (ffmpeg_exe.empty() || ffprobe_exe.empty()) { if (ffmpeg_exe.empty() || ffprobe_exe.empty()) {
return false; return false;
} }
_cached = true;
_ffmpeg_exe = ffmpeg_exe;
_ffprobe_exe = ffprobe_exe;
return true; return true;
} }