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

**URL:** <https://qa.fmod.com/t/getting-assertion-length-blocksize-failed-in-custom-output-plugin/16041>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [August 4, 2020, 2:15pm UTC](https://qa.fmod.com/t/getting-assertion-length-blocksize-failed-in-custom-output-plugin/16041 "2020-08-04T14:15:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vedranskarica](https://avatars.discourse-cdn.com/v4/letter/v/5f8ce5/32.png) [@vedranskarica](https://qa.fmod.com/u/vedranskarica)\
**Post date:** [August 4, 2020, 2:15pm UTC](https://qa.fmod.com/t/getting-assertion-length-blocksize-failed-in-custom-output-plugin/16041/1 "2020-08-04T14:15:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [August 5, 2020, 1:30am UTC](https://qa.fmod.com/t/getting-assertion-length-blocksize-failed-in-custom-output-plugin/16041/2 "2020-08-05T01:30:27Z")

</div>

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](https://fmod.com/resources/documentation-api?version=2.1&page=plugin-api-output.html#fmod_output_method) instead.
