From f8236d61b07aa0a76e2367a6e578104e82b25bd9 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 7 Jan 2021 15:44:42 +0000 Subject: [PATCH] Refactored Venue::load to take a Program --- .../3rdParty/choc/containers/choc_Value.h | 8 ++++---- .../soul_core/venue/soul_RenderingVenue.cpp | 20 ++++++++----------- source/modules/soul_core/venue/soul_Venue.h | 2 +- .../audio_player/soul_AudioPlayer.cpp | 4 ++-- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/soul/3rdParty/choc/containers/choc_Value.h b/include/soul/3rdParty/choc/containers/choc_Value.h index 85186f2..64d21a7 100644 --- a/include/soul/3rdParty/choc/containers/choc_Value.h +++ b/include/soul/3rdParty/choc/containers/choc_Value.h @@ -557,7 +557,8 @@ class ValueView final @see Value::serialise */ template - static void deserialise (InputData&, Handler&& handleResult); + static void deserialise (InputData&, Handler&& handleResult, + Allocator* allocator = nullptr); private: //============================================================================== @@ -2231,11 +2232,10 @@ void ValueView::serialise (OutputStream& output) const } template -void ValueView::deserialise (InputData& input, Handler&& handleResult) +void ValueView::deserialise (InputData& input, Handler&& handleResult, Allocator* allocator) { - FixedPoolAllocator<8192> localAllocator; ValueView result; - result.type = Type::deserialise (input, std::addressof (localAllocator)); + result.type = Type::deserialise (input, allocator); auto valueDataSize = result.type.getValueDataSize(); Type::SerialisationHelpers::expect (input.end >= input.start + valueDataSize); result.data = const_cast (input.start); diff --git a/source/modules/soul_core/venue/soul_RenderingVenue.cpp b/source/modules/soul_core/venue/soul_RenderingVenue.cpp index 9f0a067..04f99cb 100644 --- a/source/modules/soul_core/venue/soul_RenderingVenue.cpp +++ b/source/modules/soul_core/venue/soul_RenderingVenue.cpp @@ -228,28 +228,24 @@ struct RenderingVenue::Pimpl venue.removeActiveSession (*this); } - bool load (BuildBundle build, CompileTaskFinishedCallback loadFinishedCallback) override + bool load (const Program& program, CompileTaskFinishedCallback loadFinishedCallback) override { unload(); - if (build.sourceFiles.empty()) + if (program.isEmpty()) return false; - taskQueue.addTask ([this, build = std::move (build), + taskQueue.addTask ([this, program, callback = std::move (loadFinishedCallback)] (TaskThread::ShouldStopFlag& cancelled) { CompileMessageList messageList; + bool ok = performer->load (messageList, program); - if (auto program = Compiler::build (messageList, build)) - { - bool ok = performer->load (messageList, program); - - if (cancelled) - return; + if (cancelled) + return; - if (ok) - setState (SessionState::loaded); - } + if (ok) + setState (SessionState::loaded); callback (messageList); }); diff --git a/source/modules/soul_core/venue/soul_Venue.h b/source/modules/soul_core/venue/soul_Venue.h index 258bcd6..9a84a2c 100644 --- a/source/modules/soul_core/venue/soul_Venue.h +++ b/source/modules/soul_core/venue/soul_Venue.h @@ -72,7 +72,7 @@ class Venue getInputEndpoints() and getOutputEndpoints() methods become available, so you can query and connect them to data sources before calling link(). */ - virtual bool load (BuildBundle, CompileTaskFinishedCallback loadFinishedCallback) = 0; + virtual bool load (const Program&, CompileTaskFinishedCallback loadFinishedCallback) = 0; /** When a program has been loaded, this returns a list of the input endpoints that the program provides. diff --git a/source/modules/soul_venue_audioplayer/audio_player/soul_AudioPlayer.cpp b/source/modules/soul_venue_audioplayer/audio_player/soul_AudioPlayer.cpp index ed52687..a80755d 100644 --- a/source/modules/soul_venue_audioplayer/audio_player/soul_AudioPlayer.cpp +++ b/source/modules/soul_venue_audioplayer/audio_player/soul_AudioPlayer.cpp @@ -51,9 +51,9 @@ struct AudioPlayerVenue::Pimpl : private AudioMIDISystem::Callback unload(); } - bool load (BuildBundle build, CompileTaskFinishedCallback loadFinishedCallback) override + bool load (const Program& program, CompileTaskFinishedCallback loadFinishedCallback) override { - return session->load (std::move (build), + return session->load (program, [clientCallback = std::move (loadFinishedCallback)] (const CompileMessageList& messages) { clientCallback (messages);