comparison TestInitialise.cpp @ 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 e48fdc8de790
children b1bc4d045a4b
comparison
equal deleted inserted replaced
22:ca6803a93bb7 23:28097c1b3de4
57 TestLengthyConstructor::m_registrar("F2 Lengthy constructor"); 57 TestLengthyConstructor::m_registrar("F2 Lengthy constructor");
58 58
59 static const size_t _step = 1000; 59 static const size_t _step = 1000;
60 60
61 Test::Results 61 Test::Results
62 TestSampleRates::test(string key, Options) 62 TestSampleRates::test(string key, Options options)
63 { 63 {
64 int rates[] = 64 int rates[] =
65 { 1, 800, 10099, 11024, 44100, 48000, 96000, 192000, 201011, 1094091 }; 65 { 1, 800, 10099, 11024, 44100, 48000, 96000, 192000, 201011, 1094091 };
66 66
67 Results r; 67 Results r;
68 68
69 if (options & Verbose) {
70 cout << " ";
71 }
72
69 for (int i = 0; i < int(sizeof(rates)/sizeof(rates[0])); ++i) { 73 for (int i = 0; i < int(sizeof(rates)/sizeof(rates[0])); ++i) {
70 74
71 int rate = rates[i]; 75 int rate = rates[i];
76
77 if (options & Verbose) {
78 cout << "[" << rate << "Hz] " << flush;
79 }
80
72 auto_ptr<Plugin> p(load(key, rate)); 81 auto_ptr<Plugin> p(load(key, rate));
73 Plugin::FeatureSet f; 82 Plugin::FeatureSet f;
74 float **data = 0; 83 float **data = 0;
75 size_t channels = 0; 84 size_t channels = 0;
76 size_t count = 100; 85 size_t count = 100;
77 86
78 if (!initAdapted(p.get(), channels, _step, _step, r)) continue; 87 Results subr;
88 if (!initAdapted(p.get(), channels, _step, _step, subr)) {
89 // This is not an error; the plugin can legitimately
90 // refuse to initialise at weird settings and that's often
91 // the most acceptable result
92 if (!subr.empty()) {
93 r.push_back(note(subr.begin()->message()));
94 }
95 continue;
96 }
79 97
80 data = createTestAudio(channels, _step, count); 98 data = createTestAudio(channels, _step, count);
81 for (size_t i = 0; i < count; ++i) { 99 for (size_t i = 0; i < count; ++i) {
82 float *ptr[channels]; 100 float *ptr[channels];
83 size_t idx = i * _step; 101 size_t idx = i * _step;
88 } 106 }
89 Plugin::FeatureSet fs = p->getRemainingFeatures(); 107 Plugin::FeatureSet fs = p->getRemainingFeatures();
90 appendFeatures(f, fs); 108 appendFeatures(f, fs);
91 destroyTestAudio(data, channels); 109 destroyTestAudio(data, channels);
92 } 110 }
111
112 if (options & Verbose) cout << endl;
93 113
94 // We can't actually do anything meaningful with our results. 114 // We can't actually do anything meaningful with our results.
95 // We're really just testing to see whether the plugin crashes. I 115 // We're really just testing to see whether the plugin crashes. I
96 // wonder whether it's possible to do any better? If not, we 116 // wonder whether it's possible to do any better? If not, we
97 // should probably report our limitations 117 // should probably report our limitations