summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-12-23 14:23:31 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-12-23 14:23:31 +0000
commit8e201d18a88d4cf4ca1163c32bdc2400c28ead8d (patch)
treeb6da9d0a2d28c05b874f23c0ba7e389dc8fd7d7c /libs
parent27ab352f5bd33072cd8e26441ed440ad155dbb64 (diff)
a few more EPA tweaks (from 2.X)
git-svn-id: svn://localhost/ardour2/branches/3.0@8340 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/audioengine.cc4
-rw-r--r--libs/pbd/epa.cc21
-rw-r--r--libs/pbd/pbd/epa.h6
3 files changed, 23 insertions, 8 deletions
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 9feb87ba95..683dbca422 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -1263,12 +1263,14 @@ AudioEngine::connect_to_jack (string client_name, string session_uuid)
const char *server_name = NULL;
EnvironmentalProtectionAgency* global_epa = EnvironmentalProtectionAgency::get_global_epa ();
- EnvironmentalProtectionAgency current_epa; // saves current settings and restores on exit from this scope
+ EnvironmentalProtectionAgency current_epa (false);
/* revert all environment settings back to whatever they were when ardour started
*/
if (global_epa) {
+ current_epa.arm ();
+ current_epa.save ();
global_epa->restore ();
}
diff --git a/libs/pbd/epa.cc b/libs/pbd/epa.cc
index 71387b4c23..8665823d77 100644
--- a/libs/pbd/epa.cc
+++ b/libs/pbd/epa.cc
@@ -29,14 +29,25 @@ using namespace std;
EnvironmentalProtectionAgency* EnvironmentalProtectionAgency::_global_epa = 0;
-EnvironmentalProtectionAgency::EnvironmentalProtectionAgency ()
+EnvironmentalProtectionAgency::EnvironmentalProtectionAgency (bool arm)
+ : _armed (arm)
{
- save ();
+ if (_armed) {
+ save ();
+ }
}
EnvironmentalProtectionAgency::~EnvironmentalProtectionAgency()
{
- restore ();
+ if (_armed) {
+ restore ();
+ }
+}
+
+void
+EnvironmentalProtectionAgency::arm ()
+{
+ _armed = true;
}
void
@@ -63,9 +74,9 @@ EnvironmentalProtectionAgency::save ()
}
}
void
-EnvironmentalProtectionAgency::restore ()
+EnvironmentalProtectionAgency::restore () const
{
- for (map<string,string>::iterator i = e.begin(); i != e.end(); ++i) {
+ for (map<string,string>::const_iterator i = e.begin(); i != e.end(); ++i) {
cerr << "Restore [" << i->first << "] = " << i->second << endl;
setenv (i->first.c_str(), i->second.c_str(), 1);
}
diff --git a/libs/pbd/pbd/epa.h b/libs/pbd/pbd/epa.h
index 39773313ec..b2708fbd4c 100644
--- a/libs/pbd/pbd/epa.h
+++ b/libs/pbd/pbd/epa.h
@@ -27,16 +27,18 @@ namespace PBD {
class EnvironmentalProtectionAgency {
public:
- EnvironmentalProtectionAgency ();
+ EnvironmentalProtectionAgency (bool arm=true);
~EnvironmentalProtectionAgency ();
- void restore ();
+ void arm ();
void save ();
+ void restore () const;
static EnvironmentalProtectionAgency* get_global_epa () { return _global_epa; }
static void set_global_epa (EnvironmentalProtectionAgency* epa) { _global_epa = epa; }
private:
+ bool _armed;
std::map<std::string,std::string> e;
static EnvironmentalProtectionAgency* _global_epa;
};