Skip to content

Commit

Permalink
Fix a race when the playback parameters were changing under a patch w…
Browse files Browse the repository at this point in the history
…hich was being recompiled
  • Loading branch information
cesaref committed Jun 18, 2024
1 parent ae561a0 commit 70d13fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions include/cmajor/helpers/cmaj_AudioMIDIPerformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ inline bool AudioMIDIPerformer::Builder::connectAudioInputTo (const std::vector<
{
CMAJ_ASSERT (inputChannels.size() == endpointChannels.size());

result->preRenderFunctions.clear();

if (auto numChannelsInEndpoint = getNumFloatChannelsInStream (endpoint))
{
ensureInputScratchBufferChannelCount (numChannelsInEndpoint);
Expand Down
7 changes: 6 additions & 1 deletion include/cmajor/helpers/cmaj_Patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ struct Patch::PatchRenderer : public std::enable_shared_from_this<PatchRenderer
//==============================================================================
void build (cmaj::Engine& engine,
LoadParams& loadParams,
const PlaybackParams& playbackParams,
PlaybackParams playbackParams,
bool shouldResolveExternals,
bool shouldLink,
const cmaj::CacheDatabaseInterface::Ptr& c,
Expand All @@ -1001,6 +1001,7 @@ struct Patch::PatchRenderer : public std::enable_shared_from_this<PatchRenderer
{
try
{
configuredPlaybackParams = playbackParams;
manifest = std::move (loadParams.manifest);

if (! loadProgram (engine, playbackParams, shouldResolveExternals, checkForStopSignal))
Expand Down Expand Up @@ -1485,6 +1486,7 @@ struct Patch::PatchRenderer : public std::enable_shared_from_this<PatchRenderer
PatchManifest manifest;
cmaj::DiagnosticMessageList errors;
std::string lastBuildLog;
PlaybackParams configuredPlaybackParams;

choc::value::Value programDetails;
std::vector<PatchParameterPtr> parameterList;
Expand Down Expand Up @@ -2356,6 +2358,9 @@ inline void Patch::setNewRenderer (std::shared_ptr<PatchRenderer> newRenderer)
if (renderer == nullptr && newRenderer == nullptr)
return;

if (currentPlaybackParams != newRenderer->configuredPlaybackParams)
return;

if (stopPlayback)
stopPlayback();

Expand Down

0 comments on commit 70d13fa

Please sign in to comment.