Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

AAX safety check on block size changes #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion WDL/IPlug/IPlugAAX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,13 @@ void IPlugAAX::RenderAudio(AAX_SIPlugRenderInfo* ioRenderInfo)
SetOutputChannelConnections(numOutChannels, NOutChannels() - numOutChannels, false);

AttachOutputBuffers(0, NOutChannels(), ioRenderInfo->mAudioOutputs);


// make sure that we initialize the plugin with the correct block size
if(GetBlockSize() != numSamples) {
SetBlockSize(numSamples);
Reset();
}

if (bypass)
{
PassThroughBuffers(0.0f, numSamples);
Expand Down
56 changes: 31 additions & 25 deletions WDL/IPlug/IPlugVST3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,31 +641,37 @@ IPlugView* PLUGIN_API IPlugVST3::createView (const char* name)

tresult PLUGIN_API IPlugVST3::setEditorState(IBStream* state)
{
TRACE;
WDL_MutexLock lock(&mMutex);

ByteChunk chunk;
SerializeState(&chunk); // to get the size

if (chunk.Size() > 0)
{
state->read(chunk.GetBytes(), chunk.Size());
UnserializeState(&chunk, 0);

int32 savedBypass = 0;

if (state->read (&savedBypass, sizeof (int32)) != kResultOk)
{
return kResultFalse;
}

mIsBypassed = (bool) savedBypass;

RedrawParamControls();
return kResultOk;
}

return kResultFalse;
TRACE;
WDL_MutexLock lock(&mMutex);

ByteChunk chunk;

const int bytesPerBlock = 128;
char buffer[bytesPerBlock];

for (;;)
{
Steinberg::int32 bytesRead = 0;
auto status = state->read (buffer, (Steinberg::int32) bytesPerBlock, &bytesRead);

if (bytesRead <= 0 || status != kResultTrue)
break;

chunk.PutBytes(buffer, bytesRead);
}
UnserializeState(&chunk,0);

int32 savedBypass = 0;

if (state->read (&savedBypass, sizeof (int32)) != kResultOk) {
return kResultFalse;
}

mIsBypassed = (bool) savedBypass;

RedrawParamControls();
return kResultOk;

}

tresult PLUGIN_API IPlugVST3::getEditorState(IBStream* state)
Expand Down