Skip to content

Commit

Permalink
Refactored Venue::load to take a Program
Browse files Browse the repository at this point in the history
  • Loading branch information
julianstorer committed Jan 7, 2021
1 parent 900bbde commit f8236d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
8 changes: 4 additions & 4 deletions include/soul/3rdParty/choc/containers/choc_Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ class ValueView final
@see Value::serialise
*/
template <typename Handler>
static void deserialise (InputData&, Handler&& handleResult);
static void deserialise (InputData&, Handler&& handleResult,
Allocator* allocator = nullptr);

private:
//==============================================================================
Expand Down Expand Up @@ -2231,11 +2232,10 @@ void ValueView::serialise (OutputStream& output) const
}

template <typename Handler>
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<uint8_t*> (input.start);
Expand Down
20 changes: 8 additions & 12 deletions source/modules/soul_core/venue/soul_RenderingVenue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion source/modules/soul_core/venue/soul_Venue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f8236d6

Please sign in to comment.