Cache the process binary path and name
This commit is contained in:
+11
-11
@@ -299,12 +299,12 @@ void ReadALConfig(void) noexcept
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
|
||||
PathNamePair ppath = GetProcBinary();
|
||||
if(!ppath.path.empty())
|
||||
std::string ppath{GetProcBinary().path};
|
||||
if(!ppath.empty())
|
||||
{
|
||||
ppath.path += "\\alsoft.ini";
|
||||
TRACE("Loading config %s...\n", ppath.path.c_str());
|
||||
al::ifstream f{ppath.path.c_str()};
|
||||
ppath += "\\alsoft.ini";
|
||||
TRACE("Loading config %s...\n", ppath.c_str());
|
||||
al::ifstream f{ppath};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
@@ -422,14 +422,14 @@ void ReadALConfig(void) noexcept
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
|
||||
PathNamePair ppath = GetProcBinary();
|
||||
if(!ppath.path.empty())
|
||||
std::string ppath{GetProcBinary().path};
|
||||
if(!ppath.empty())
|
||||
{
|
||||
if(ppath.path.back() != '/') ppath.path += "/alsoft.conf";
|
||||
else ppath.path += "alsoft.conf";
|
||||
if(ppath.back() != '/') ppath += "/alsoft.conf";
|
||||
else ppath += "alsoft.conf";
|
||||
|
||||
TRACE("Loading config %s...\n", ppath.path.c_str());
|
||||
al::ifstream f{ppath.path};
|
||||
TRACE("Loading config %s...\n", ppath.c_str());
|
||||
al::ifstream f{ppath};
|
||||
if(f.is_open())
|
||||
LoadConfigFromFile(f);
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ pa_context *connect_context(pa_threaded_mainloop *loop, ALboolean silent)
|
||||
{
|
||||
const char *name{"OpenAL Soft"};
|
||||
|
||||
PathNamePair binname = GetProcBinary();
|
||||
const PathNamePair &binname = GetProcBinary();
|
||||
if(!binname.fname.empty())
|
||||
name = binname.fname.c_str();
|
||||
|
||||
|
||||
+1
-1
@@ -223,7 +223,7 @@ using ifstream = std::ifstream;
|
||||
#include <string>
|
||||
|
||||
struct PathNamePair { std::string path, fname; };
|
||||
PathNamePair GetProcBinary(void);
|
||||
const PathNamePair &GetProcBinary(void);
|
||||
|
||||
#ifdef HAVE_DYNLOAD
|
||||
void *LoadLib(const char *name);
|
||||
|
||||
+9
-5
@@ -310,9 +310,11 @@ void FPUCtl::leave() noexcept
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
PathNamePair GetProcBinary()
|
||||
const PathNamePair &GetProcBinary()
|
||||
{
|
||||
PathNamePair ret;
|
||||
static PathNamePair ret;
|
||||
if(!ret.fname.empty() || !ret.path.empty())
|
||||
return ret;
|
||||
|
||||
al::vector<WCHAR> fullpath(256);
|
||||
DWORD len;
|
||||
@@ -477,11 +479,13 @@ void SetRTPriority(void)
|
||||
|
||||
#else
|
||||
|
||||
PathNamePair GetProcBinary()
|
||||
const PathNamePair &GetProcBinary()
|
||||
{
|
||||
PathNamePair ret;
|
||||
al::vector<char> pathname;
|
||||
static PathNamePair ret;
|
||||
if(!ret.fname.empty() || !ret.path.empty())
|
||||
return ret;
|
||||
|
||||
al::vector<char> pathname;
|
||||
#ifdef __FreeBSD__
|
||||
size_t pathlen;
|
||||
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
|
||||
|
||||
Reference in New Issue
Block a user