3 * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "../backend/engine/CarlaEngineInternal.hpp"
20 #include "CarlaPlugin.hpp"
22 #include "CarlaHost.h"
23 #include "CarlaUtils.hpp"
25 // -----------------------------------------------------------------------
27 CARLA_BACKEND_START_NAMESPACE
29 class CarlaEngineDummy
: public CarlaEngine
38 bool init(const char* const clientName
) override
41 pData
->bufferSize
= 512;
42 pData
->sampleRate
= 44100.0;
43 return CarlaEngine::init(clientName
);
49 return CarlaEngine::close();
52 bool isRunning() const noexcept override
57 bool isOffline() const noexcept override
62 EngineType
getType() const noexcept override
64 return kEngineTypePlugin
;
67 const char* getCurrentDriverName() const noexcept override
76 CARLA_BACKEND_END_NAMESPACE
78 // -----------------------------------------------------------------------
80 CARLA_BACKEND_USE_NAMESPACE
82 #define TEST_NAME "TestName"
84 void testEngine(CarlaEngine
* const eng
)
86 assert(eng
->getMaxClientNameSize() != 0);
87 assert(eng
->getMaxPortNameSize() != 0);
88 assert(eng
->getCurrentPluginCount() == 0);
89 assert(eng
->getMaxPluginNumber() == 0);
90 assert(! eng
->isRunning());
91 assert(eng
->getPlugin(0) == nullptr);
93 const char* name1
= eng
->getUniquePluginName(TEST_NAME
);
94 const char* name2
= eng
->getUniquePluginName(TEST_NAME
);
95 const char* name3
= eng
->getUniquePluginName(TEST_NAME
);
97 assert(name1
!= nullptr);
98 assert(name2
!= nullptr);
99 assert(name3
!= nullptr);
100 assert(std::strcmp(name1
, TEST_NAME
) == 0);
101 assert(std::strcmp(name2
, TEST_NAME
) == 0);
102 assert(std::strcmp(name3
, TEST_NAME
) == 0);
109 assert(eng
->getCurrentPluginCount() == 0);
110 assert(eng
->getMaxPluginNumber() != 0);
111 assert(eng
->isRunning());
112 assert(eng
->getPlugin(0) == nullptr);
114 name1
= eng
->getUniquePluginName(TEST_NAME
);
115 name2
= eng
->getUniquePluginName(TEST_NAME
);
116 name3
= eng
->getUniquePluginName(TEST_NAME
);
118 assert(name1
!= nullptr);
119 assert(name2
!= nullptr);
120 assert(name3
!= nullptr);
121 assert(std::strcmp(name1
, TEST_NAME
) == 0);
122 assert(std::strcmp(name2
, TEST_NAME
) == 0);
123 assert(std::strcmp(name3
, TEST_NAME
) == 0);
130 // test quick init & close 3 times
141 // add as much plugins as possible
144 if (! eng
->addPlugin(PLUGIN_INTERNAL
, nullptr, TEST_NAME
, "bypass"))
147 assert(eng
->getCurrentPluginCount() != 0);
148 assert(eng
->getCurrentPluginCount() == eng
->getMaxPluginNumber());
149 assert(eng
->getCurrentPluginCount() == MAX_DEFAULT_PLUGINS
);
156 assert(CarlaEngine::getDriverCount() != 0);
159 for (uint i
=0, count
=CarlaEngine::getDriverCount(); i
< count
&& i
< 4; ++i
)
161 if (i
== 1 || i
== 2) continue;
162 carla_stdout("driver %i/%i: %s", i
+1, count
, CarlaEngine::getDriverName(i
));
164 if (const char* const* const devNames
= CarlaEngine::getDriverDeviceNames(i
))
166 for (uint j
=0; devNames
[j
] != nullptr; ++j
)
168 CarlaEngine::getDriverDeviceInfo(i
, devNames
[j
]);
174 assert(CarlaPlugin::getNativePluginCount() != 0);
176 for (size_t i
=0, count
=CarlaPlugin::getNativePluginCount(); i
< count
; ++i
)
178 assert(CarlaPlugin::getNativePluginDescriptor(i
) != nullptr);
184 // if (CarlaEngine* const eng = CarlaEngine::newDriverByName("PulseAudio"))