Fix for compiling on gcc4.
authorTaybin Rutkin <taybin@taybin.com>
Tue, 11 Jul 2006 04:15:29 +0000 (04:15 +0000)
committerTaybin Rutkin <taybin@taybin.com>
Tue, 11 Jul 2006 04:15:29 +0000 (04:15 +0000)
AudioLibrary now stateful.

git-svn-id: svn://localhost/ardour2/trunk@675 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audio_library.h
libs/ardour/audio_library.cc
libs/ardour/globals.cc
libs/ardour/session_state.cc

index 2f9e84551b5c523ac0779a70a178e31414e5f253..3d4585fbd88bd81fde6d77a8ddd2601648183a2e 100644 (file)
 
 #include <sigc++/signal.h>
 
+#include <pbd/stateful.h>
+
 using std::vector;
 using std::string;
 using std::map;
 
 namespace ARDOUR {
 
-class AudioLibrary
+class AudioLibrary : public Stateful
 {
   public:
        AudioLibrary ();
        ~AudioLibrary ();
 
+       XMLNode& get_state (void);
+       int set_state (const XMLNode&);
+
        void set_paths (vector<string> paths);
        vector<string> get_paths ();
        void scan_paths ();
index 7f421e86c817dc4074aa19cdbfed9e29bc98a55d..168a1dcf5dd0b623e16d0a9c676fb020d3495187 100644 (file)
@@ -75,11 +75,16 @@ AudioLibrary::AudioLibrary ()
 
        lrdf_free_statements(matches);
 
+       XMLNode* state = instant_xml(X_("AudioLibrary"), get_user_ardour_path());
+       if (state) {
+               set_state(*state);
+       }
        scan_paths();
 }
 
 AudioLibrary::~AudioLibrary ()
 {
+       add_instant_xml(get_state(), get_user_ardour_path());
 }
 
 void
@@ -429,5 +434,50 @@ AudioLibrary::safe_file_extension(string file)
         file.rfind(".maud")== string::npos &&
         file.rfind(".vwe") == string::npos &&
         file.rfind(".paf") == string::npos &&
+#ifdef HAVE_COREAUDIO
+               file.rfind(".mp3") == string::npos &&
+               file.rfind(".aac") == string::npos &&
+               file.rfind(".mp4") == string::npos &&
+#endif // HAVE_COREAUDIO
         file.rfind(".voc") == string::npos);
 }
+
+XMLNode&
+AudioLibrary::get_state ()
+{
+       XMLNode* root = new XMLNode(X_("AudioLibrary"));
+       
+       for (vector<string>::iterator i = sfdb_paths.begin(); i != sfdb_paths.end(); ++i) {
+               XMLNode* node = new XMLNode(X_("Path"));
+               node->add_property("value", *i);
+               root->add_child_nocopy(*node);
+       }
+       
+       return *root;
+}
+
+int
+AudioLibrary::set_state (const XMLNode& node)
+{
+       if (node.name() != X_("AudioLibrary")) {
+               fatal << "programming error: AudioLibrary: incorrect XML node sent to set_state()" << endmsg;
+               return -1;
+       }
+       
+       XMLNodeList nodes = node.children(X_("Path"));
+       
+       vector<string> paths;
+       XMLProperty* prop;
+       XMLNode* child;
+       for (XMLNodeConstIterator iter = nodes.begin(); iter != nodes.end(); ++iter) {
+               child = *iter;
+               
+               if ((prop = child->property(X_("value"))) != 0) {
+                       paths.push_back(prop->value());
+               }
+       }
+       
+       sfdb_paths = paths;
+       
+       return 0;
+}
index e9fc1ddfafd716d5475f030d6c96da879c85f8b9..ffcc4ddb059434e58a54f66458e2b95eabe63ef0 100644 (file)
@@ -32,6 +32,7 @@
 #include <lrdf.h>
 
 #include <pbd/error.h>
+#include <pbd/id.h>
 #include <pbd/strsplit.h>
 
 #include <midi++/port.h>
@@ -195,7 +196,7 @@ ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization)
 
        (void) bindtextdomain(PACKAGE, LOCALEDIR);
 
-       ID::init ();
+       PBD::ID::init ();
 
        Config = new Configuration;
 
@@ -294,7 +295,7 @@ ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization)
                
                info << "No H/W specific optimizations in use" << endmsg;
        }
-       
+
        lrdf_init();
        Library = new AudioLibrary;
 
index 1e355990b4db6b35dc13c00a55259c6a7d9df0b1..b6b9746c922f6c759063efe4c4e73fb1667a5515 100644 (file)
@@ -1499,7 +1499,7 @@ Session::set_state (const XMLNode& node)
 
        _state_of_the_state = StateOfTheState (_state_of_the_state|CannotSave);
        
-       if (node.name() != "Session"){
+       if (node.name() != X_("Session")){
                fatal << _("programming error: Session: incorrect XML node sent to set_state()") << endmsg;
                return -1;
        }