aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alconfig.cpp22
-rw-r--r--Alc/backends/pulseaudio.cpp2
-rw-r--r--Alc/compat.h2
-rw-r--r--Alc/helpers.cpp14
4 files changed, 22 insertions, 18 deletions
diff --git a/Alc/alconfig.cpp b/Alc/alconfig.cpp
index 40131cc1..eecaf6fc 100644
--- a/Alc/alconfig.cpp
+++ b/Alc/alconfig.cpp
@@ -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);
}
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 8428b9d8..16e64cdf 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -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();
diff --git a/Alc/compat.h b/Alc/compat.h
index 18ba8da9..dc652bca 100644
--- a/Alc/compat.h
+++ b/Alc/compat.h
@@ -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);
diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp
index beee4bff..2db544b8 100644
--- a/Alc/helpers.cpp
+++ b/Alc/helpers.cpp
@@ -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 };