# Migrating from OpenAL

**URL:** <https://qa.fmod.com/t/migrating-from-openal/18936>\
**Category:** FMOD Engine\
**Tags:** windows, cpp\
**Created:** [June 24, 2022, 1:34am UTC](https://qa.fmod.com/t/migrating-from-openal/18936 "2022-06-24T01:34:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Speak4Erase](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Speak4Erase](https://qa.fmod.com/u/Speak4Erase)\
**Post date:** [June 24, 2022, 1:34am UTC](https://qa.fmod.com/t/migrating-from-openal/18936/1 "2022-06-24T01:34:47Z")

</div>

Hey, I have a project/game engine that currently relies on OpenAL for audio, and I was wondering what the process for transitioning to FMOD would look like.

Has anyone done this kind of thing before? If so, what’d they suggest I do?

I also use MingW to compile my project. Does this add any more complications besides not being able to use the C++ ABI?  
(Heck, what’s the difference between the C++ ABI and the C ABI anyway?)

---

<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:** [June 30, 2022, 3:04am UTC](https://qa.fmod.com/t/migrating-from-openal/18936/2 "2022-06-30T03:04:15Z")

</div>

> [@Speak4Erase](#):
>
> Has anyone done this kind of thing before? If so, what’d they suggest I do?

I am not familiar with OpenAL so I am not entirely equipped to suggest the details of a transition to FMOD. Skimming the docs there are certainly high level similarities in terms of creating listeners, creating instances of source/sounds, loading audio data into them from disc, setting their positions in 3D space and finally releasing them. So on the surface it seems to me that FMOD has an obvious analog for each OpenAL API call. One potential gotcha is the need to call `System::update()` as well as `sleep` to playback audio in FMOD; I see in OpenAL you play out a source like this:

```cpp
while (source_state == AL_PLAYING) {
	alGetSourcei(source, AL_SOURCE_STATE, &source_state);
	TEST_ERROR("source state get");
}

```

While in FMOD you update the system object and sleep for a duration:

```cpp
while(true)
{
	result = system->update();
	ERRCHECK(result);
	sleep(50)
}

```

In terms of software design, I guess a good place to start would be to extract a common interface from your exsting audio functionality and reimplement it using FMOD. The [Bridge Pattern](https://sourcemaking.com/design_patterns/bridge) would be a good approach to allow a graduated transition while supporting both audio systems.

> [@Speak4Erase](#):
>
> I also use MingW to compile my project. Does this add any more complications besides not being able to use the C++ ABI?  
> (Heck, what’s the difference between the C++ ABI and the C ABI anyway?)

I am not sure what you mean about MinGW not being able to use the C++ ABI. MinGW can compile C++ code on Windows without issue, and this includes anything using the FMOD C++ API.  
There are many differences between a C and C++ ABI on a given platform- I think this might be a little out of scope for the forums, but here is an interesting presentation on ABIs and how the C and C++ ABIs tend to differ:  
[Jonathan Wakely- What is an ABI and Why is it So Complicated](https://accu.org/conf-docs/PDFs_2015/JonathanWakely-What%20Is%20An%20ABI%20And%20Why%20Is%20It%20So%20Complicated.pdf)

---

<div class="post-metadata">

**Author:** ![Speak4Erase](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Speak4Erase](https://qa.fmod.com/u/Speak4Erase)\
**Post date:** [June 30, 2022, 3:49pm UTC](https://qa.fmod.com/t/migrating-from-openal/18936/3 "2022-06-30T15:49:33Z")

</div>

Thanks for the response! I’ll look into using the bridge pattern.

> [@jeff\_fmod](#):
>
> I am not sure what you mean about MinGW not being able to use the C++ ABI. MinGW can compile C++ code on Windows without issue, and this includes anything using the FMOD C++ API.

I’ve seen people on the forums here saying that due to the way different compilers mangle C++ function names you can’t use the FMOD C++ ABI with MinGW. I tested it out myself, and ran into a bunch of `undefined reference to <function name>` errors in linking, unfortunately.

---

<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 4, 2022, 2:31am UTC](https://qa.fmod.com/t/migrating-from-openal/18936/4 "2022-07-04T02:31:58Z")

</div>

> [@Speak4Erase](#):
>
> I tested it out myself, and ran into a bunch of `undefined reference to <function name>` errors in linking, unfortunately.

I see what you mean now, you are correct only the C ABI is supported for MinGW- apologies for the oversight there.

> [@Speak4Erase](#):
>
> Does this add any more complications

There is one other thing to look out for on Windows- you should call `CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)` before making any FMOD calls, and call `CoUninitialize()` during cleanup. More details on this, and a few other potential gotchas on Windows can be found in the [Windows Platform Details](https://fmod.com/resources/documentation-api?version=2.02&page=platforms-win.html#libraries) section of the API docs.

---

<div class="post-metadata">

**Author:** ![Speak4Erase](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Speak4Erase](https://qa.fmod.com/u/Speak4Erase)\
**Post date:** [July 5, 2022, 10:12pm UTC](https://qa.fmod.com/t/migrating-from-openal/18936/5 "2022-07-05T22:12:53Z")

</div>

Alright, thank you!
