Get rid of engine context pointer

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-11-04 11:13:45 +00:00
parent 0c916ae619
commit d6d0e0f734
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0

View file

@ -39,7 +39,6 @@
#include <settings.hpp> #include <settings.hpp>
#include <system.hpp> #include <system.hpp>
#include <random.hpp> #include <random.hpp>
#include <context.hpp>
#include <patch.hpp> #include <patch.hpp>
#include <plugin.hpp> #include <plugin.hpp>
@ -61,27 +60,23 @@ struct ReadWriteMutex {
pthread_rwlock_t rwlock; pthread_rwlock_t rwlock;
ReadWriteMutex() { ReadWriteMutex() {
if (pthread_rwlock_init(&rwlock, NULL)) if (pthread_rwlock_init(&rwlock, nullptr))
throw Exception("pthread_rwlock_init failed"); throw Exception("pthread_rwlock_init failed");
} }
~ReadWriteMutex() { ~ReadWriteMutex() {
pthread_rwlock_destroy(&rwlock); pthread_rwlock_destroy(&rwlock);
} }
void lockReader() { void lockReader() {
if (pthread_rwlock_rdlock(&rwlock)) DISTRHO_SAFE_ASSERT_RETURN(pthread_rwlock_rdlock(&rwlock) == 0,);
throw Exception("pthread_rwlock_rdlock failed");
} }
void unlockReader() { void unlockReader() {
if (pthread_rwlock_unlock(&rwlock)) DISTRHO_SAFE_ASSERT_RETURN(pthread_rwlock_unlock(&rwlock) == 0,);
throw Exception("pthread_rwlock_unlock failed");
} }
void lockWriter() { void lockWriter() {
if (pthread_rwlock_wrlock(&rwlock)) DISTRHO_SAFE_ASSERT_RETURN(pthread_rwlock_wrlock(&rwlock) == 0,);
throw Exception("pthread_rwlock_wrlock failed");
} }
void unlockWriter() { void unlockWriter() {
if (pthread_rwlock_unlock(&rwlock)) DISTRHO_SAFE_ASSERT_RETURN(pthread_rwlock_unlock(&rwlock) == 0,);
throw Exception("pthread_rwlock_unlock failed");
} }
}; };
@ -144,9 +139,6 @@ struct Engine::Internal {
Readers lock when using the engine's state. Readers lock when using the engine's state.
*/ */
ReadWriteMutex mutex; ReadWriteMutex mutex;
// For worker threads
Context* context;
}; };
@ -314,9 +306,6 @@ static void Engine_refreshParamHandleCache(Engine* that) {
Engine::Engine() { Engine::Engine() {
internal = new Internal; internal = new Internal;
internal->context = contextGet();
setSuggestedSampleRate(0.f);
} }
@ -987,7 +976,7 @@ void Engine::fromJson(json_t* rootJ) {
} }
catch (Exception& e) { catch (Exception& e) {
WARN("Cannot load model: %s", e.what()); WARN("Cannot load model: %s", e.what());
APP->patch->log(e.what()); // APP->patch->log(e.what());
continue; continue;
} }
@ -1009,7 +998,7 @@ void Engine::fromJson(json_t* rootJ) {
} }
catch (Exception& e) { catch (Exception& e) {
WARN("Cannot load module: %s", e.what()); WARN("Cannot load module: %s", e.what());
APP->patch->log(e.what()); // APP->patch->log(e.what());
delete module; delete module;
continue; continue;
} }