Question

Whenever I try to create a new audio context in monodroid, it fallls over telling me that openal32.dll is missing; which naturally doesn't make sense, being as this is monodroid, and openal is included as part of OpenTK.

I can only assume i'm doing something wrong, but i've used OpenTK/OpenAL before under windows and have managed just fine with similar code.

anyway here is the offending code:

        public Audio()
    {
        if (Loaded == false)
        {
            Loaded = true;
            try
            {
                try {Console.WriteLine ("Current: " + AudioContext.CurrentContext.ToString());} catch { Console.WriteLine ("no current context"); }
                try {Console.WriteLine ("Default: " + AudioContext.DefaultDevice);} catch { Console.WriteLine ("no default device"); }

                Context = new AudioContext();
                ValidContext = true; //we have a valid audio context!
            }
            catch (Exception ex)
            {
                Console.WriteLine ("Loading the audio context failed.");
                Console.WriteLine (ex.ToString ());
                Console.WriteLine (ex.Message);
                ValidContext = false; //Loading the audio context failed :(
            }
        }
    }

And here is the output:

I/monodroid-gc(24762): environment supports jni NewWeakGlobalRef

D/AndroidGameView(24762): SurfaceCreated

D/libEGL  (24762): egl.cfg not found, using default config

D/libEGL  (24762): loaded /system/lib/egl/libGLES_android.so

I/mono-stdout(24762): no current context

I/mono-stdout(24762): no default device

I/mono-stdout(24762): Loading the audio context failed.

I/mono-stdout(24762): System.TypeInitializationException: An exception was thrown by the type initializer for OpenTK.Audio.AudioContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for OpenTK.Audio.AudioDeviceEnumerator ---> System.DllNotFoundException: openal32.dll

I/mono-stdout(24762):   at (wrapper managed-to-native) OpenTK.Audio.OpenAL.Alc:MakeContextCurrent (intptr)

I/mono-stdout(24762):   at OpenTK.Audio.OpenAL.Alc.MakeContextCurrent (ContextHandle context) [0x00000] in <filename unknown>:0 

I/mono-stdout(24762):   at OpenTK.Audio.AudioDeviceEnumerator..cctor () [0x00000] in <filename unknown>:0 

I/mono-stdout(24762):   --- End of inner exception stack trace ---

I/mono-stdout(24762):   at OpenTK.Audio.AudioContext..cctor () [0x00000] in <filename unknown>:0 

I/mono-stdout(24762):   --- End of inner exception stack trace ---

I/mono-stdout(24762):   at Hardware.Audio..ctor () [0x00000] in <filename unknown>:0 

I/mono-stdout(24762): An exception was thrown by the type initializer for OpenTK.Audio.AudioContext

I/ARMAssembler(24762): generated scanline__00000177:03545444_00009001_00000000 [159 ipp] (215 ins) at [0x4fc138:0x4fc494] in 4168381 ns
Was it helpful?

Solution

openal32.dll is not included as part of OpenTK. OpenTK just has bindings for OpenAL. Just like opengl32.dll, which is included as part of your graphics card drivers, openal32.dll must be installed through audio card drivers (or a software implementation of it).

After a quick search, it looks like you need to compile a software implementation of OpenAL for Android: http://pielot.org/2010/12/14/openal-on-android/

Edit: It looks like Android prefers to use the newer OpenSL ES. If you've got a bit of time on your hands, you could try to get OpenTK's generator to generate OpenSL ES bindings for you.

This other StackOverflow question has a few other options for using OpenSL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top