Skip to content

Commit

Permalink
fix: Stability fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Nana <[email protected]>
  • Loading branch information
na2axl committed Oct 29, 2024
1 parent f956d4b commit 3e22812
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/SparkyStudios/Audio/Amplitude/Core/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ namespace SparkyStudios::Audio::Amplitude
*
* @ingroup memory
*/
class MemoryAllocator
class AM_API_PUBLIC MemoryAllocator
{
public:
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace SparkyStudios::Audio::Amplitude

void Codec::Register(Codec* codec)
{
if (lockCodecs())
if (lockCodecs() || codec == nullptr)
return;

if (Find(codec->GetName()) != nullptr)
Expand All @@ -94,7 +94,7 @@ namespace SparkyStudios::Audio::Amplitude

void Codec::Unregister(const Codec* codec)
{
if (lockCodecs())
if (lockCodecs() || codec == nullptr)
return;

CodecRegistry& codecs = codecRegistry();
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace SparkyStudios::Audio::Amplitude

void Driver::Register(Driver* driver)
{
if (lockDrivers())
if (lockDrivers() || driver == nullptr)
return;

if (Find(driver->GetName()) != nullptr)
Expand All @@ -80,7 +80,7 @@ namespace SparkyStudios::Audio::Amplitude

void Driver::Unregister(const Driver* driver)
{
if (lockDrivers())
if (lockDrivers() || driver == nullptr)
return;

DriverRegistry& drivers = driverRegistry();
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace SparkyStudios::Audio::Amplitude

void MemoryManager::Initialize(std::unique_ptr<MemoryAllocator> allocator)
{
if (gMemManager == nullptr)
if (!IsInitialized())
gMemManager = new MemoryManager(std::move(allocator));

#if !defined(AM_NO_MEMORY_STATS)
Expand Down
10 changes: 5 additions & 5 deletions src/DSP/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ namespace SparkyStudios::Audio::Amplitude
return m_name;
}

void Filter::Register(Filter* codec)
void Filter::Register(Filter* filter)
{
if (lockFilters())
if (lockFilters() || filter == nullptr)
return;

if (Find(codec->GetName()) != nullptr)
if (Find(filter->GetName()) != nullptr)
return;

FilterRegistry& filters = filterRegistry();
filters.insert(FilterImpl(codec->GetName(), codec));
filters.insert(FilterImpl(filter->GetName(), filter));
filtersCount()++;
}

void Filter::Unregister(const Filter* filter)
{
if (lockFilters())
if (lockFilters() || filter == nullptr)
return;

FilterRegistry& filters = filterRegistry();
Expand Down
4 changes: 2 additions & 2 deletions src/DSP/Resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace SparkyStudios::Audio::Amplitude

void Resampler::Register(Resampler* resampler)
{
if (lockResamplers())
if (lockResamplers() || resampler == nullptr)
return;

if (Find(resampler->GetName()) != nullptr)
Expand All @@ -79,7 +79,7 @@ namespace SparkyStudios::Audio::Amplitude

void Resampler::Unregister(const Resampler* resampler)
{
if (lockResamplers())
if (lockResamplers() || resampler == nullptr)
return;

ResamplerRegistry& resamplers = resamplerRegistry();
Expand Down
4 changes: 2 additions & 2 deletions src/Mixer/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ namespace SparkyStudios::Audio::Amplitude

void Node::Register(Node* node)
{
if (lockNodes())
if (lockNodes() || node == nullptr)
return;

if (Find(node->GetName()) != nullptr)
Expand All @@ -306,7 +306,7 @@ namespace SparkyStudios::Audio::Amplitude

void Node::Unregister(const Node* node)
{
if (lockNodes())
if (lockNodes() || node == nullptr)
return;

NodeRegistry& nodes = nodeRegistry();
Expand Down
4 changes: 2 additions & 2 deletions src/Sound/Fader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ namespace SparkyStudios::Audio::Amplitude

void Fader::Register(Fader* fader)
{
if (lockFaders())
if (lockFaders() || fader == nullptr)
return;

if (Find(fader->GetName()) != nullptr)
Expand All @@ -265,7 +265,7 @@ namespace SparkyStudios::Audio::Amplitude

void Fader::Unregister(const Fader* fader)
{
if (lockFaders())
if (lockFaders() || fader == nullptr)
return;

FaderRegistry& faders = faderRegistry();
Expand Down
1 change: 1 addition & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct AmTestListener : Catch::EventListenerBase

// Register all the default plugins shipped with the engine
Engine::RegisterDefaultPlugins();
Driver::Unregister(Driver::Find("miniaudio"));

const auto sdkPath = std::filesystem::path(std::getenv("AM_SDK_PATH"));

Expand Down
2 changes: 1 addition & 1 deletion tests/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TEST_CASE("Thread Pool Tests", "[thread][amplitude]")
auto task = std::make_shared<DummyPoolTask>(threadId);
REQUIRE_FALSE(task->IsExecuted());

bool willExecuteWorkInCallerThread = pool.GetTaskCount() >= AM_MAX_THREAD_POOL_TASKS;
bool willExecuteWorkInCallerThread = pool.GetTaskCount() > AM_MAX_THREAD_POOL_TASKS;

pool.AddTask(task);

Expand Down

0 comments on commit 3e22812

Please sign in to comment.