changeset 23:28097c1b3de4

* Add verbose option * More sensible response when a plugin legitimately refuses to initialise * Actually throw an exception when failing to load a plugin, instead of just saying that we do so in the comment but actually crashing instead
author cannam
date Mon, 08 Jun 2009 10:08:26 +0000
parents ca6803a93bb7
children 064ad81ea53c
files Test.cpp TestDefaults.cpp TestInitialise.cpp
diffstat 3 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Test.cpp	Fri Mar 20 15:57:38 2009 +0000
+++ b/Test.cpp	Mon Jun 08 10:08:26 2009 +0000
@@ -52,8 +52,10 @@
 Plugin *
 Test::load(std::string key, float rate)
 {
-    return PluginLoader::getInstance()->loadPlugin
+    Plugin *p = PluginLoader::getInstance()->loadPlugin
         (key, rate, PluginLoader::ADAPT_ALL);
+    if (!p) throw FailedToLoadPlugin();
+    return p;
 }
 
 float **
--- a/TestDefaults.cpp	Fri Mar 20 15:57:38 2009 +0000
+++ b/TestDefaults.cpp	Mon Jun 08 10:08:26 2009 +0000
@@ -118,6 +118,11 @@
             Plugin::ParameterList pl = p->getParameterDescriptors();
             for (int i = 0; i < (int)pl.size(); ++i) {
                 if (p->getParameter(pl[i].identifier) != pl[i].defaultValue) {
+                    if (options & Verbose) {
+                        cout << "Parameter: " << pl[i].identifier << endl;
+                        cout << "Expected: " << pl[i].defaultValue << endl;
+                        cout << "Actual: " << p->getParameter(pl[i].identifier) << endl;
+                    }
                     r.push_back(error("Not all parameters have their default values when queried directly after construction"));
                 }
                 p->setParameter(pl[i].identifier, pl[i].defaultValue);
--- a/TestInitialise.cpp	Fri Mar 20 15:57:38 2009 +0000
+++ b/TestInitialise.cpp	Mon Jun 08 10:08:26 2009 +0000
@@ -59,23 +59,41 @@
 static const size_t _step = 1000;
 
 Test::Results
-TestSampleRates::test(string key, Options)
+TestSampleRates::test(string key, Options options)
 {
     int rates[] =
         { 1, 800, 10099, 11024, 44100, 48000, 96000, 192000, 201011, 1094091 };
 
     Results r;
 
+    if (options & Verbose) {
+        cout << "    ";
+    }
+
     for (int i = 0; i < int(sizeof(rates)/sizeof(rates[0])); ++i) {
     
         int rate = rates[i];
+
+        if (options & Verbose) {
+            cout << "[" << rate << "Hz] " << flush;
+        }
+
         auto_ptr<Plugin> p(load(key, rate));
         Plugin::FeatureSet f;
         float **data = 0;
         size_t channels = 0;
         size_t count = 100;
 
-        if (!initAdapted(p.get(), channels, _step, _step, r)) continue;
+        Results subr;
+        if (!initAdapted(p.get(), channels, _step, _step, subr)) {
+            // This is not an error; the plugin can legitimately
+            // refuse to initialise at weird settings and that's often
+            // the most acceptable result
+            if (!subr.empty()) {
+                r.push_back(note(subr.begin()->message()));
+            }
+            continue;
+        }
 
         data = createTestAudio(channels, _step, count);
         for (size_t i = 0; i < count; ++i) {
@@ -91,6 +109,8 @@
         destroyTestAudio(data, channels);
     }
 
+    if (options & Verbose) cout << endl;
+
     // We can't actually do anything meaningful with our results.
     // We're really just testing to see whether the plugin crashes.  I
     // wonder whether it's possible to do any better?  If not, we