2012-02-28 76 views
1

每當我嘗試在monodroid中創建一個新的音頻上下文時,它會告訴我openal32.dll丟失;這自然是沒有道理的,因爲這是monodroid,Openal作爲OpenTK的一部分包含在內。如何在monodroid中用OpenAL創建音頻上下文?

我只能假設我做錯了什麼,但我在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。

快速搜索之後,它看起來像你需要編譯的OpenAL的軟件實現的Android:http://pielot.org/2010/12/14/openal-on-android/

編輯:它看起來像Android一樣喜歡使用較新的OpenSL ES。如果您手頭有一段時間,您可以嘗試讓OpenTK的生成器爲您生成OpenSL ES綁定。

This other StackOverflow question還有其他一些使用OpenSL的選項。

+0

感謝您的幫助,我將着眼於嘗試編譯OpenAL。 – Danny 2012-02-28 15:37:53