Fix for compiling on gcc4.

AudioLibrary now stateful.


git-svn-id: svn://localhost/ardour2/trunk@675 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Taybin Rutkin
2006-07-11 04:15:29 +00:00
parent c3b4df9867
commit 2161752a1b
4 changed files with 60 additions and 4 deletions

View File

@@ -28,18 +28,23 @@
#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 ();

View 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;
}

View 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;

View 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;
}