Getting "assertion: 'length == blockSize' failed" in custom output plugin

I’m trying to make a custom output plugin and I used the mp3_output example from the SDK. Inside the OutputCallback function I do:

PSHORT destptr = (PSHORT)malloc(readLength);
unsigned int len = readLength / 2; /* /2 = stereo */;
FMOD_RESULT result = output_state->readfrommixer(output_state, destptr, len);

It throws an error

assertion: ‘length == blockSize’ failed

followed by

Error during mix. FMOD_RESULT = 28

I’m assuming I have either the wrong buffer size or I’m requesting the wrong length, but even if I decouple the values and try different combinations nothing seems to work.
The only thing that doesn’t throw an error is if len=1.

What exactly is the “length == blockSize” reffering to and how to fix this?

The expected length is the DSP buffer size, you receive this value during the init callback. If you would like to consume different amounts it’s recommended you use the buffered mix instead.