Commits

André Schnabel committed 8828991

Minor sound changes

Comments (0)

Files changed (4)

 
 		[Conditional("DEBUG")]
 		public static void CheckAlError() {
+			if(Globals.NoMusic && Globals.NoSound) return;
 			var err = AL.GetError();
 			if(err != ALError.NoError) {
 				throw new Exception("OpenAL error: " + AL.GetErrorString(err));
 		/// Initializes a new instance of the <see cref="Sound"/> class.
 		/// </summary>
 		public Sound(string path) {
+			if(Globals.NoSound) return;
+
 			buffer = AL.GenBuffer();
 			CheckAlError();
 
 		/// <see cref="Sound"/> was occupying.
 		/// </remarks>
 		public void Dispose() {
+			if(Globals.NoSound) return;
+
 			AL.SourceStop(source);
 			CheckAlError();
 
 		/// Play this instance of this sound.
 		/// </summary>
 		public void Play() {
+			if(Globals.NoSound) return;
+
 			AL.SourcePlay(source);
 			CheckAlError();
 		}
 		/// True if an instance of this sound is currently playing.
 		/// </summary>
 		public bool IsPlaying {
-			get { return AL.GetSourceState(source) == ALSourceState.Playing; }
+			get { 
+				if(Globals.NoSound) return false;
+				return AL.GetSourceState(source) == ALSourceState.Playing;
+			}
 		}
 
 		/// <summary>
 		/// Stop all instances of this sound.
 		/// </summary>
 		public void Stop() {
+			if(Globals.NoSound) return;
+
 			AL.SourceStop(source);
 			CheckAlError();
 		}
     <Reference Include="System.Core" />
     <Reference Include="System.Drawing" />
     <Reference Include="System.Xml" />
-    <Reference Include="OpenTK">
-      <HintPath>..\..\..\Downloads\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
-    </Reference>
     <Reference Include="csogg">
       <HintPath>libs\csogg.dll</HintPath>
     </Reference>
     <Reference Include="Newtonsoft.Json">
       <HintPath>libs\DotNet4JSON\Newtonsoft.Json.dll</HintPath>
     </Reference>
+    <Reference Include="OpenTK">
+      <HintPath>..\..\..\Downloads\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Cameras\Camera.cs" />
     <Compile Include="Utilities\KeyboardSnapshot.cs" />
     <Compile Include="Utilities\LeakChecker.cs" />
     <Compile Include="Rendering\Fonts\SimpleFont.cs" />
-    <Compile Include="Rendering\Sprites\TransformedSpriteBatch.cs" />
     <Compile Include="Audio\Song.cs" />
     <Compile Include="Audio\Sound.cs" />
     <Compile Include="Math\Matrix4.cs" />
     <Compile Include="Rendering\GeometryCache.cs" />
     <Compile Include="Rendering\PosColVertex.cs" />
     <Compile Include="Math\BoundingBox.cs" />
+    <Compile Include="Rendering\Sprites\TransformedSpriteCache.cs" />
+    <Compile Include="Rendering\ShaderProgram.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
     <DebugType>full</DebugType>
     <Optimize>False</Optimize>
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG;MOBILE;IOS;IOS_OAL_SND</DefineConstants>
+    <DefineConstants>DEBUG;MOBILE;IOS</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>False</ConsolePause>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>False</ConsolePause>
-    <DefineConstants>MOBILE;IOS;IOS_OAL_SND</DefineConstants>
+    <DefineConstants>MOBILE;IOS</DefineConstants>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />

Platforms/IPhone/IPhonePlatform.cs

 		private ContextHandle context;
 
 #if IOS_OAL
+		// TODO: Fix SwapBuffers SIGSEGV related to this code!
 		private void InitOpenAL() {
-			if(Globals.NoSound && Globals.NoMusic) return;
+			if(Globals.NoSound) return;
 
-			/*AudioSession.Initialize();
+			AudioSession.Initialize();
 			try {
 				AudioSession.Category = AudioSession.OtherAudioIsPlaying ? AudioSessionCategory.AmbientSound : AudioSessionCategory.SoloAmbientSound;
-			} catch(AudioSessionException ase) {}*/
+			} catch(AudioSessionException ase) {}
 
 			device = Alc.OpenDevice(null);
 			if(device == IntPtr.Zero) {
 			};
 		}
 		private void DisposeOpenAL() {
-			if(Globals.NoSound && Globals.NoMusic) return;
+			if(Globals.NoSound) return;
 
 			Alc.MakeContextCurrent (ContextHandle.Zero);
 			Sound.CheckAlError();