# 2.02.01 - bug in registerCodec?

**URL:** <https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [July 22, 2021, 1:28am UTC](https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465 "2021-07-22T01:28:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![csnxs](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/csnxs/32/2453_2.png) [@csnxs](https://qa.fmod.com/u/csnxs)\
**Post date:** [July 22, 2021, 1:28am UTC](https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465/1 "2021-07-22T01:28:38Z")

</div>

I appear to have run into a bug while experimenting with custom codecs earlier today: calling `registerCodec` always seems to return `FMOD_ERR_PLUGIN_VERSION`, regardless of whether the `apiversion` field of the given `FMOD_CODEC_DESCRIPTION` struct is set to `FMOD_CODEC_PLUGIN_VERSION` or not. Interestingly though, custom codecs seem to work fine when loaded as a separate DLL via `loadPlugin`.  
I’ve managed to reproduce this with both my own codec plugin and the included `fmod_codec_raw.cpp` example (completely unmodified), with both MSYS2 MinGW and VS 2019.

Is this a bug or have I managed to miss something here?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [July 23, 2021, 12:48am UTC](https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465/2 "2021-07-23T00:48:35Z")

</div>

Thanks for flagging this, it looks like the registerCodec call hasn’t been updated to copy the apiversion field which was added to FMOD\_CODEC\_DESCRIPTION fairly recently.  
I’ll make a task for the dev team to fix that for a later release, in the meantime loadPlugin is working fine with dlls (as you’ve noticed) so hopefully that doesn’t get too inconvenient until we’ve got a fix.

---

<div class="post-metadata">

**Author:** ![csnxs](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/csnxs/32/2453_2.png) [@csnxs](https://qa.fmod.com/u/csnxs)\
**Post date:** [July 23, 2021, 3:04am UTC](https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465/3 "2021-07-23T03:04:45Z")

</div>

Fortunately the inconvenience isn’t much more than writing a few more lines of CMake so I can deal with this workaround for now 😃  
Thanks for confirming and raising this, greatly appreciated!

---

<div class="post-metadata">

**Author:** ![csnxs](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/csnxs/32/2453_2.png) [@csnxs](https://qa.fmod.com/u/csnxs)\
**Post date:** [November 23, 2021, 10:34pm UTC](https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465/4 "2021-11-23T22:34:08Z")

</div>

A much belated thank you for fixing the bug - and an apology for bumping this somewhat old thread… however I have noticed another minor mistake with codec stuff (present in the latest release, 2.02.04):

In `fmod_codec.h`,

```auto
#define FMOD_CODEC_METADATA(_state, _tagtype, _name, _data, _datalen, _datatype, _unique) \
    (_state)->functions->metadata(_size, _tagtype, _name, _data, _datalen, _datatype, _unique)
// ^^^^^ here

```

The first parameter passed to the function in the definition should be `_state`, not `_size`. Fortunately this one is easily worked around by just re-`#define`ing it correctly.

Cheers… and thanks for the great audio library!

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [November 25, 2021, 2:34am UTC](https://qa.fmod.com/t/2-02-01-bug-in-registercodec/17465/5 "2021-11-25T02:34:25Z")

</div>

Thanks for flagging, I have passed this along to the Dev team to fix up!
