kcat / alure

Alure is a utility library for OpenAL, providing a C++ API and managing common tasks that include file loading, caching, and streaming
zlib License
70 stars 20 forks source link

"Called context is not current" exception #19

Closed karamellpelle closed 6 years ago

karamellpelle commented 6 years ago

The newest Alure works: It builds and the examples run well.

I pulled the latest Alure into my project. I had to do some minor modifications in my code to adapt to the newer Alure API, in particular using PIMPL objects in favor of pointers, and now everything compiles.

However, my program gets killed by Alure: Alure throws "Called context is not current" exception(s). They seems to come from void CheckContext(const ContextImpl *ctx)/void CheckContext(const ContextImpl &ctx). I don't know why this happens. Your examples work well. It may have something to do with threads in my program that I am not aware of.

Do @kcat have some suggestions of what causes this error in my program?

Thank you for this great OpenAL library! 🚁

kcat commented 6 years ago

However, my program gets killed by Alure: Alure throws "Called context is not current" exception(s). They seems to come from void CheckContext(const ContextImpl *ctx)/void CheckContext(const ContextImpl &ctx). I don't know why this happens.

That generally means you forgot to call alure::Context::MakeCurrent. One other possibility, since you mentioned updating Alure to the newer pImpl-based API, check that you held on to the DeviceManager after setting up the device and context. With the new interface, if that goes out of scope and gets destroyed, everything shuts down automatically.

karamellpelle commented 6 years ago

Thank you very much @kcat! Keeping the DeviceManager did the trick.