Fixed AudioContext.IsCurrent getter (would throw if no context was current).

This commit is contained in:
the_fiddler 2008-01-18 15:10:25 +00:00
parent ab1b65520d
commit 50fd919bae
2 changed files with 31 additions and 8 deletions

View file

@ -6,18 +6,20 @@ using OpenTK.Audio;
using AlContext = System.IntPtr;
using AlDevice = System.IntPtr;
using System.Diagnostics;
namespace Examples
{
[Example("AudioContext Test", ExampleCategory.Test)]
class TestApp
{
public static void GetOpenALErrors( IntPtr device )
public static void PrintOpenALErrors( IntPtr device )
{
ALError AlErr = AL.GetError();
AlcError AlcErr = Alc.GetError( device );
// AudioContext should throw on errors, so no need to test them manually.
//AlcError AlcErr = Alc.GetError(device);
AlutError AlutErr = Alut.GetError();
Console.WriteLine( " Al: " + AlErr + " Alc: " + AlcErr + " Alut: " + AlcErr + " " + Alut.GetErrorString( AlutErr ) );
Console.WriteLine("Al: " + AlErr + " Alut: " + Alut.GetErrorString(AlutErr));
}
public static void Main()
@ -29,7 +31,26 @@ namespace Examples
{
AudioContext context = new AudioContext();
/*
Trace.WriteLine("Testing AudioContext functions.");
Trace.Indent();
Trace.WriteLine("Suspend()...");
context.Suspend();
Trace.Assert(!context.IsProcessing);
Trace.WriteLine("Process()...");
context.Process();
Trace.Assert(context.IsProcessing);
Trace.WriteLine("MakeCurrent()...");
context.MakeCurrent();
Trace.Assert(context.IsCurrent);
Trace.WriteLine("IsCurrent = false...");
context.IsCurrent = false;
Trace.Assert(!context.IsCurrent);
#if false
AlDevice MyDevice;
AlContext MyContext;
@ -100,7 +121,7 @@ namespace Examples
{
Console.WriteLine( "Failed to find suitable Device." );
}
*/
#endif
/*
include <stdlib.h>
include <AL/alut.h>

View file

@ -348,7 +348,9 @@ namespace OpenTK.Audio
if (available_contexts.Count == 0)
return false;
else
return AudioContext.available_contexts[(ContextHandle)Alc.GetCurrentContext()] == this;
{
return AudioContext.CurrentContext == this;
}
}
}
set