0

I am facing a problem in using OpenSLES on Android 2.3.

When I tried to create an engine object, I got the following error: slcreateengine while another engine is active

I know OpenSLES for Android(2.3? because I didn't find this issue on Android 4.x) supports a single engine, but I simply don't know where is the another engine from.

Is there any interface in OpenSLES to check whether there is already an active engine or not?

Thanks in advance for any hints!

jenny
  • 93
  • 1
  • 6

1 Answers1

0

This is boggling me as well as most of the time the application works, but every now and then I find this error occurs leading to a unusable openSL engine, but I only noted this on Android 2.3.

The SL_RESULT_RESOURCE_ERROR can be thrown by a varitude of reasons, for instance a pthread error, out-of-memory etc. But these would return appropriate error codes.

It's more likely it boils down to application architecture, are there multiple bits of code that create an engine object or is there just one entry point ? You can't actually retrieve active engine objects from OpenSL, so you must store all pointers/references to the engine objects you pass to the slCreateEngine-method. It might be a good idea to check their status (and close engines) prior to running the create engine method, as it is possible that it is firing multiple times (for instance, your Activity's onCreate / onPause / onResume-methods might by triggering a new creation).

Igor Zinken
  • 884
  • 5
  • 19
  • I solved the problem by using a static variable for the engine object hence as long as there is one active engine, no new one will be created... – jenny Jan 28 '14 at 09:33