summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-12-23 04:17:45 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-12-23 04:17:45 +0000
commite99087a273d746195fb94240ece46a4cf7ac554b (patch)
treea5ffc3b4e89be36cfd6abddd52169395f7767509
parent4336bb25d739cd007811ccd0298a15acc5e20787 (diff)
add EPA stuff from 2.X
git-svn-id: svn://localhost/ardour2/branches/3.0@8337 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/main.cc3
-rw-r--r--libs/ardour/audioengine.cc11
-rw-r--r--libs/pbd/epa.cc72
-rw-r--r--libs/pbd/pbd/epa.h46
4 files changed, 132 insertions, 0 deletions
diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc
index 899e8b5789..827425c321 100644
--- a/gtk2_ardour/main.cc
+++ b/gtk2_ardour/main.cc
@@ -26,6 +26,7 @@
#include <gtkmm/settings.h>
#include "pbd/error.h"
+#include "pbd/epa.h"
#include "pbd/file_utils.h"
#include "pbd/textreceiver.h"
#include "pbd/failed_constructor.h"
@@ -308,6 +309,8 @@ fixup_bundle_environment (int argc, char* argv[])
return;
}
+ EnvironmentalProtectionAgency::set_global_epa (new EnvironmentalProtectionAgency);
+
Glib::ustring exec_path = argv[0];
Glib::ustring dir_path = Glib::path_get_dirname (Glib::path_get_dirname (exec_path));
Glib::ustring path;
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 7da6876577..9feb87ba95 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -31,6 +31,7 @@
#include "pbd/pthread_utils.h"
#include "pbd/stacktrace.h"
#include "pbd/unknown_type.h"
+#include "pbd/epa.h"
#include "midi++/port.h"
#include "midi++/mmc.h"
@@ -1261,6 +1262,16 @@ AudioEngine::connect_to_jack (string client_name, string session_uuid)
jack_status_t status;
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
+
+ /* revert all environment settings back to whatever they were when ardour started
+ */
+
+ if (global_epa) {
+ global_epa->restore ();
+ }
+
jack_client_name = client_name; /* might be reset below */
#ifdef HAVE_JACK_SESSION
if (! session_uuid.empty())
diff --git a/libs/pbd/epa.cc b/libs/pbd/epa.cc
new file mode 100644
index 0000000000..71387b4c23
--- /dev/null
+++ b/libs/pbd/epa.cc
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <cstdlib>
+#include <iostream>
+
+#include "pbd/epa.h"
+
+extern char** environ;
+
+using namespace PBD;
+using namespace std;
+
+EnvironmentalProtectionAgency* EnvironmentalProtectionAgency::_global_epa = 0;
+
+EnvironmentalProtectionAgency::EnvironmentalProtectionAgency ()
+{
+ save ();
+}
+
+EnvironmentalProtectionAgency::~EnvironmentalProtectionAgency()
+{
+ restore ();
+}
+
+void
+EnvironmentalProtectionAgency::save ()
+{
+ e.clear ();
+
+ for (size_t i = 0; environ[i]; ++i) {
+
+ string estring = environ[i];
+ string::size_type equal = estring.find_first_of ('=');
+
+ if (equal == string::npos) {
+ /* say what? an environ value without = ? */
+ continue;
+ }
+
+ string before = estring.substr (0, equal);
+ string after = estring.substr (equal+1);
+
+ cerr << "Save [" << before << "] = " << after << endl;
+
+ e.insert (pair<string,string>(before,after));
+ }
+}
+void
+EnvironmentalProtectionAgency::restore ()
+{
+ for (map<string,string>::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
new file mode 100644
index 0000000000..39773313ec
--- /dev/null
+++ b/libs/pbd/pbd/epa.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __libpbd_epa_h__
+#define __libpbd_epa_h__
+
+#include <map>
+#include <string>
+
+namespace PBD {
+
+class EnvironmentalProtectionAgency {
+ public:
+ EnvironmentalProtectionAgency ();
+ ~EnvironmentalProtectionAgency ();
+
+ void restore ();
+ void save ();
+
+ static EnvironmentalProtectionAgency* get_global_epa () { return _global_epa; }
+ static void set_global_epa (EnvironmentalProtectionAgency* epa) { _global_epa = epa; }
+
+ private:
+ std::map<std::string,std::string> e;
+ static EnvironmentalProtectionAgency* _global_epa;
+};
+
+}
+
+#endif /* __libpbd_epa_h__ */