如何在 monodroid 中使用 OpenAL 创建音频上下文?
Posted
技术标签:
【中文标题】如何在 monodroid 中使用 OpenAL 创建音频上下文?【英文标题】:How can I create an audio context with OpenAL in monodroid? 【发布时间】:2012-03-17 12:19:25 【问题描述】:每当我尝试在 monodroid 中创建新的音频上下文时,它都会告诉我 openal32.dll 丢失了;这自然是没有意义的,因为这是 monodroid,并且 openal 包含在 OpenTK 中。
我只能假设我做错了什么,但我之前在 windows 下使用过 OpenTK/OpenAL,并且使用类似的代码管理得很好。
无论如何这里是有问题的代码:
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 :(
这是输出:
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
【问题讨论】:
【参考方案1】:openal32.dll 不包含在 OpenTK 中。 OpenTK 只有 OpenAL 的绑定。与作为显卡驱动程序一部分的 opengl32.dll 一样,openal32.dll 必须通过声卡驱动程序(或它的软件实现)安装。
经过快速搜索,看来你需要为Android编译一个OpenAL的软件实现:http://pielot.org/2010/12/14/openal-on-android/
编辑:Android 似乎更喜欢使用较新的 OpenSL ES。如果您有一点时间,可以尝试让 OpenTK 的生成器为您生成 OpenSL ES 绑定。
This other *** question 有几个其他使用 OpenSL 的选项。
【讨论】:
感谢您的帮助,我会考虑尝试编译 OpenAL。以上是关于如何在 monodroid 中使用 OpenAL 创建音频上下文?的主要内容,如果未能解决你的问题,请参考以下文章