-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbe886a
commit e47ef37
Showing
7 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set(MOSTLYHARMLESS_TEST_SOURCE | ||
${CMAKE_CURRENT_SOURCE_DIR}/mostlyharmless_TestCreatePluginImpl.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/mostlyharmless_TestDescriptor.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/utils/mostlyharmless_TaskThreadTests.cpp | ||
PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// Created by Syl on 12/08/2024. | ||
// | ||
#include <mostly_harmless/mostlyharmless_Plugin.h> | ||
namespace mostly_harmless::entry { | ||
const clap_plugin* clap_create_plugin(const clap_plugin_factory* /*f*/, const clap_host* /*h*/, const char* /*id*/) { | ||
return nullptr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
#include <mostly_harmless/mostlyharmless_Descriptor.h> | ||
namespace mostly_harmless { | ||
// clang-format off | ||
static BusConfig s_audioBusConfig { BusConfig::InputOutput }; | ||
static BusConfig s_noteBusConfig { BusConfig::None }; | ||
|
||
static std::vector<const char*> s_features { "audio-effect", nullptr }; | ||
static clap_plugin_descriptor s_descriptor{ | ||
.clap_version = CLAP_VERSION, | ||
.id = "slma.gain", | ||
.name = "Gain", | ||
.vendor = "", | ||
.url = "", | ||
.manual_url = "", | ||
.support_url = "", | ||
.version = "", | ||
.description = "", | ||
.features = s_features.data() | ||
}; | ||
|
||
clap_plugin_descriptor& getDescriptor() { | ||
return s_descriptor; | ||
} | ||
|
||
BusConfig getAudioBusConfig() noexcept { | ||
return s_audioBusConfig; | ||
} | ||
|
||
BusConfig getNoteBusConfig() noexcept { | ||
return s_noteBusConfig; | ||
} | ||
// clang-format on | ||
} // namespace mostly_harmless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// Created by Syl on 12/08/2024. | ||
// | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <mostly_harmless/utils/mostlyharmless_TaskThread.h> | ||
#include <mutex> | ||
namespace mostly_harmless::testing { | ||
TEST_CASE("Test TaskThread") { | ||
std::mutex mutex; | ||
mostly_harmless::utils::TaskThread taskThread; | ||
SECTION("Wait for lock") { | ||
auto x{ false }; | ||
auto task = [&mutex, &x]() -> void { | ||
std::scoped_lock<std::mutex> sl{ mutex }; | ||
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
x = true; | ||
}; | ||
taskThread.action = std::move(task); | ||
taskThread.perform(); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
REQUIRE(taskThread.isThreadRunning()); | ||
// Sleep for a ms so the task has a chance to acquire the mutex.. | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
std::scoped_lock<std::mutex> sl{ mutex }; | ||
REQUIRE(x); | ||
REQUIRE(!taskThread.isThreadRunning()); | ||
} | ||
|
||
SECTION("Kill") { | ||
auto task = [&taskThread]() -> void { | ||
while(!taskThread.threadShouldExit()); | ||
}; | ||
taskThread.action = std::move(task); | ||
taskThread.perform(); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
REQUIRE(taskThread.isThreadRunning()); | ||
taskThread.signalThreadShouldExit(); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
REQUIRE(!taskThread.isThreadRunning()); | ||
} | ||
|
||
SECTION("Sleep/Wake") { | ||
auto task = [&taskThread]() -> void { | ||
taskThread.sleep(); | ||
}; | ||
taskThread.action = std::move(task); | ||
taskThread.perform(); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
REQUIRE(taskThread.isThreadRunning()); | ||
taskThread.wake(); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
REQUIRE(!taskThread.isThreadRunning()); | ||
} | ||
} | ||
} |