summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-06 19:05:23 +0000
committerDavid Robillard <d@drobilla.net>2006-09-06 19:05:23 +0000
commitdac2461ba66560c00efb43a12e35394a698b60f7 (patch)
treeaff258db86692a028d544045b8a26e2df4b78a19
parent32672ca258231aea42c8868357b55ac46397084f (diff)
downloadingen-dac2461ba66560c00efb43a12e35394a698b60f7.tar.gz
ingen-dac2461ba66560c00efb43a12e35394a698b60f7.tar.bz2
ingen-dac2461ba66560c00efb43a12e35394a698b60f7.zip
Fixed LADSPA plugins with invalid OSC path port names (eg containing spaces).
Fixed node destruction. git-svn-id: http://svn.drobilla.net/lad/ingen@114 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/common/util/Path.h75
-rw-r--r--src/libs/engine/LADSPANode.cpp2
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp4
3 files changed, 78 insertions, 3 deletions
diff --git a/src/common/util/Path.h b/src/common/util/Path.h
index d79a95c2..353ecaca 100644
--- a/src/common/util/Path.h
+++ b/src/common/util/Path.h
@@ -94,6 +94,81 @@ public:
return true;
}
+ /** Convert a string in to a valid full path.
+ *
+ * This will make a best effort at turning @a str into a complete, valid
+ * Path, and will always return one.
+ */
+ static string pathify(const std::basic_string<char>& str)
+ {
+ string path = str;
+
+ if (path.length() == 0)
+ return "/"; // this might not be wise
+
+ // Must start with a /
+ if (path.at(0) != '/')
+ path = string("/").append(path);
+
+ // Must not end with a slash unless "/"
+ if (path.length() > 1 && path.at(path.length()-1) == '/')
+ path = path.substr(0, path.length()-1); // chop trailing slash
+
+ assert(path.find_last_of("/") != string::npos);
+
+ // Replace any invalid characters with "." (for lack of a better idea)
+ for (size_t i=0; i < path.length(); ++i) {
+ if (path.at(i) < 32 || path.at(i) > 126
+ || path.at(i) == ' '
+ || path.at(i) == '#'
+ || path.at(i) == '*'
+ || path.at(i) == ','
+ || path.at(i) == '?'
+ || path.at(i) == '['
+ || path.at(i) == ']'
+ || path.at(i) == '{'
+ || path.at(i) == '}') {
+ path[i] = '.';
+ }
+ }
+
+ assert(is_valid(path));
+
+ return path;
+ }
+
+ /** Convert a string into a valid name (or "method" - tokens between slashes)
+ *
+ * This will strip all slashes and always return a valid name/method.
+ */
+ static string nameify(const std::basic_string<char>& str)
+ {
+ string name = str;
+
+ if (name.length() == 0)
+ return "."; // this might not be wise
+
+ // Replace any invalid characters with "." (for lack of a better idea)
+ for (size_t i=0; i < name.length(); ++i) {
+ if (name.at(i) < 32 || name.at(i) > 126
+ || name.at(i) == ' '
+ || name.at(i) == '#'
+ || name.at(i) == '*'
+ || name.at(i) == ','
+ || name.at(i) == '?'
+ || name.at(i) == '['
+ || name.at(i) == ']'
+ || name.at(i) == '{'
+ || name.at(i) == '}'
+ || name.at(i) == '/') {
+ name[i] = '.';
+ }
+ }
+
+ return name;
+ }
+
+
/** Return the name of this object (everything after the last '/').
* This is the "method name" for OSC paths.
*/
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index e6003d90..0be82819 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -75,7 +75,7 @@ LADSPANode::instantiate()
Port* port = NULL;
for (size_t j=0; j < _descriptor->PortCount; ++j) {
- port_name = _descriptor->PortNames[j];
+ port_name = Path::nameify(_descriptor->PortNames[j]);
string::size_type slash_index;
// Name mangling, to guarantee port names are unique
diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp
index d373389b..d55a2935 100644
--- a/src/libs/engine/events/DestroyEvent.cpp
+++ b/src/libs/engine/events/DestroyEvent.cpp
@@ -138,8 +138,8 @@ DestroyEvent::execute(SampleCount offset)
void
DestroyEvent::post_process()
{
- assert(_source);
- _source->unblock();
+ if (_source)
+ _source->unblock();
if (m_node == NULL) {
if (m_path == "/")