mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
Speed up recent session display (for many large sessions)
- don't parse XML into XMLTree - only read the file, extract relevant elements - don't read session-template contents, only test file
This commit is contained in:
parent
9a46d593cb
commit
e1ca4b2887
4 changed files with 57 additions and 57 deletions
|
|
@ -2050,7 +2050,6 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
||||||
|
|
||||||
void save_as_bring_callback (uint32_t, uint32_t, std::string);
|
void save_as_bring_callback (uint32_t, uint32_t, std::string);
|
||||||
|
|
||||||
static int get_session_info_from_path (XMLTree& state_tree, const std::string& xmlpath);
|
|
||||||
static const uint32_t session_end_shift;
|
static const uint32_t session_end_shift;
|
||||||
|
|
||||||
std::string _template_state_dir;
|
std::string _template_state_dir;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace ARDOUR {
|
||||||
};
|
};
|
||||||
|
|
||||||
LIBARDOUR_API void find_route_templates (std::vector<TemplateInfo>& template_names);
|
LIBARDOUR_API void find_route_templates (std::vector<TemplateInfo>& template_names);
|
||||||
LIBARDOUR_API void find_session_templates (std::vector<TemplateInfo>& template_names);
|
LIBARDOUR_API void find_session_templates (std::vector<TemplateInfo>& template_names, bool read_xml = false);
|
||||||
|
|
||||||
LIBARDOUR_API std::string session_template_dir_to_file (std::string const &);
|
LIBARDOUR_API std::string session_template_dir_to_file (std::string const &);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4353,70 +4353,70 @@ Session::rename (const std::string& new_name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
Session::get_session_info_from_path (XMLTree& tree, const string& xmlpath)
|
|
||||||
{
|
|
||||||
if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tree.read (xmlpath)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Session::get_info_from_path (const string& xmlpath, float& sample_rate, SampleFormat& data_format)
|
Session::get_info_from_path (const string& xmlpath, float& sample_rate, SampleFormat& data_format)
|
||||||
{
|
{
|
||||||
XMLTree tree;
|
|
||||||
bool found_sr = false;
|
bool found_sr = false;
|
||||||
bool found_data_format = false;
|
bool found_data_format = false;
|
||||||
|
|
||||||
if (get_session_info_from_path (tree, xmlpath)) {
|
if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
|
||||||
|
if (ctxt == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
xmlDocPtr doc = xmlCtxtReadFile (ctxt, xmlpath.c_str(), NULL, XML_PARSE_HUGE);
|
||||||
|
|
||||||
|
if (doc == NULL) {
|
||||||
|
xmlFreeParserCtxt(ctxt);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlNodePtr node = xmlDocGetRootElement(doc);
|
||||||
|
|
||||||
|
if (node == NULL) {
|
||||||
|
xmlFreeParserCtxt(ctxt);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sample rate */
|
/* sample rate */
|
||||||
|
|
||||||
XMLProperty const * prop;
|
xmlAttrPtr attr;
|
||||||
XMLNode const * root (tree.root());
|
for (attr = node->properties; attr; attr = attr->next) {
|
||||||
|
if (!strcmp ((const char*)attr->name, "sample-rate") && attr->children) {
|
||||||
if ((prop = root->property (X_("sample-rate"))) != 0) {
|
sample_rate = atoi ((char*)attr->children->content);
|
||||||
sample_rate = atoi (prop->value());
|
found_sr = true;
|
||||||
found_sr = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const XMLNodeList& children (root->children());
|
|
||||||
for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) {
|
|
||||||
const XMLNode* child = *c;
|
|
||||||
if (child->name() == "Config") {
|
|
||||||
const XMLNodeList& options (child->children());
|
|
||||||
for (XMLNodeList::const_iterator oc = options.begin(); oc != options.end(); ++oc) {
|
|
||||||
XMLNode const * option = *oc;
|
|
||||||
XMLProperty const * name = option->property("name");
|
|
||||||
|
|
||||||
if (!name) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name->value() == "native-file-data-format") {
|
|
||||||
XMLProperty const * value = option->property ("value");
|
|
||||||
if (value) {
|
|
||||||
SampleFormat fmt = (SampleFormat) string_2_enum (option->property ("value")->value(), fmt);
|
|
||||||
data_format = fmt;
|
|
||||||
found_data_format = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found_data_format) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node = node->children;
|
||||||
|
while (node != NULL) {
|
||||||
|
if (strcmp((const char*) node->name, "Config")) {
|
||||||
|
node = node->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (node = node->children; node; node = node->next) {
|
||||||
|
xmlChar* pv = xmlGetProp (node, (const xmlChar*)"name");
|
||||||
|
if (pv && !strcmp ((const char*)pv, "native-file-data-format")) {
|
||||||
|
xmlFree (pv);
|
||||||
|
xmlChar* val = xmlGetProp (node, (const xmlChar*)"value");
|
||||||
|
if (val) {
|
||||||
|
SampleFormat fmt = (SampleFormat) string_2_enum (string ((const char*)val), fmt);
|
||||||
|
data_format = fmt;
|
||||||
|
found_data_format = true;
|
||||||
|
}
|
||||||
|
xmlFree (val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
xmlFree (pv);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlFreeParserCtxt(ctxt);
|
||||||
|
|
||||||
return !(found_sr && found_data_format); // zero if they are both found
|
return !(found_sr && found_data_format); // zero if they are both found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ session_template_dir_to_file (string const & dir)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
find_session_templates (vector<TemplateInfo>& template_names)
|
find_session_templates (vector<TemplateInfo>& template_names, bool read_xml)
|
||||||
{
|
{
|
||||||
vector<string> templates;
|
vector<string> templates;
|
||||||
|
|
||||||
|
|
@ -95,10 +95,11 @@ find_session_templates (vector<TemplateInfo>& template_names)
|
||||||
for (vector<string>::iterator i = templates.begin(); i != templates.end(); ++i) {
|
for (vector<string>::iterator i = templates.begin(); i != templates.end(); ++i) {
|
||||||
string file = session_template_dir_to_file (*i);
|
string file = session_template_dir_to_file (*i);
|
||||||
|
|
||||||
XMLTree tree;
|
if (read_xml) {
|
||||||
|
XMLTree tree;
|
||||||
if (!tree.read (file.c_str())) {
|
if (!tree.read (file.c_str())) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateInfo rti;
|
TemplateInfo rti;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue