removed some Debugging code from SoundSystem.Windows.XAudio and optimized error handling for Windows 8
This commit is contained in:
parent
6e01932070
commit
ef4cb698e4
@ -18,6 +18,8 @@ namespace SimpleModernUI
|
|||||||
GraphicsDeviceManager graphics;
|
GraphicsDeviceManager graphics;
|
||||||
SpriteBatch spriteBatch;
|
SpriteBatch spriteBatch;
|
||||||
|
|
||||||
|
Texture2D texture;
|
||||||
|
|
||||||
public Game1()
|
public Game1()
|
||||||
{
|
{
|
||||||
graphics = new GraphicsDeviceManager(this);
|
graphics = new GraphicsDeviceManager(this);
|
||||||
@ -32,6 +34,9 @@ namespace SimpleModernUI
|
|||||||
protected override void LoadContent()
|
protected override void LoadContent()
|
||||||
{
|
{
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
|
|
||||||
|
texture = new Texture2D(GraphicsDevice, 1, 1);
|
||||||
|
texture.SetData<Color>(new Color[] { Color.White });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UnloadContent()
|
protected override void UnloadContent()
|
||||||
@ -54,6 +59,10 @@ namespace SimpleModernUI
|
|||||||
{
|
{
|
||||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||||
|
|
||||||
|
spriteBatch.Begin();
|
||||||
|
spriteBatch.Draw(texture, new Rectangle(10, 10, 64, 64), Color.Green);
|
||||||
|
spriteBatch.End();
|
||||||
|
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,19 +85,7 @@ namespace ANX.SoundSystem.Windows.XAudio
|
|||||||
dopplerScale = 1f;
|
dopplerScale = 1f;
|
||||||
speedOfSound = 343.5f;
|
speedOfSound = 343.5f;
|
||||||
|
|
||||||
try
|
InitializeDevice();
|
||||||
{
|
|
||||||
device = new XAudio2(XAudio2Flags.DebugEngine, ProcessorSpecifier.AnyProcessor);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
device = null;
|
|
||||||
//TODO: error handling
|
|
||||||
System.Diagnostics.Debugger.Break();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device != null)
|
|
||||||
MasteringVoice = new MasteringVoice(device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Creator()
|
~Creator()
|
||||||
@ -106,39 +94,74 @@ namespace ANX.SoundSystem.Windows.XAudio
|
|||||||
{
|
{
|
||||||
MasteringVoice.DestroyVoice();
|
MasteringVoice.DestroyVoice();
|
||||||
MasteringVoice.Dispose();
|
MasteringVoice.Dispose();
|
||||||
|
MasteringVoice = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device != null)
|
if (device != null)
|
||||||
|
{
|
||||||
device.Dispose();
|
device.Dispose();
|
||||||
|
device = null;
|
||||||
MasteringVoice = null;
|
}
|
||||||
device = null;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
internal void InitializeDevice()
|
||||||
|
{
|
||||||
|
if (device == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
device = new XAudio2(XAudio2Flags.None, ProcessorSpecifier.AnyProcessor);
|
||||||
|
}
|
||||||
|
catch (SharpDX.SharpDXException ex)
|
||||||
|
{
|
||||||
|
if (ex.ResultCode == 0x80040154)
|
||||||
|
{
|
||||||
|
// couldn't initialize XAudio: "class not registered"
|
||||||
|
device = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device != null)
|
||||||
|
{
|
||||||
|
MasteringVoice = new MasteringVoice(device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddInSystemFactory.Instance.PreventSystemChange(AddInType.SoundSystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IAudioListener CreateAudioListener()
|
public IAudioListener CreateAudioListener()
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAudioEmitter CreateAudioEmitter()
|
public IAudioEmitter CreateAudioEmitter()
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region CreateSoundEffect
|
#region CreateSoundEffect
|
||||||
public ISoundEffect CreateSoundEffect(SoundEffect parent, Stream stream)
|
public ISoundEffect CreateSoundEffect(SoundEffect parent, Stream stream)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
return new XAudioSoundEffect(stream);
|
return new XAudioSoundEffect(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISoundEffect CreateSoundEffect(SoundEffect parent, byte[] buffer, int offset, int count, int sampleRate,
|
public ISoundEffect CreateSoundEffect(SoundEffect parent, byte[] buffer, int offset, int count, int sampleRate,
|
||||||
AudioChannels channels, int loopStart, int loopLength)
|
AudioChannels channels, int loopStart, int loopLength)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
return new XAudioSoundEffect(buffer, offset, count, sampleRate, channels, loopStart, loopLength);
|
return new XAudioSoundEffect(buffer, offset, count, sampleRate, channels, loopStart, loopLength);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -146,7 +169,8 @@ namespace ANX.SoundSystem.Windows.XAudio
|
|||||||
#region CreateSoundEffectInstance
|
#region CreateSoundEffectInstance
|
||||||
public ISoundEffectInstance CreateSoundEffectInstance(ISoundEffect nativeSoundEffect)
|
public ISoundEffectInstance CreateSoundEffectInstance(ISoundEffect nativeSoundEffect)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
return new XAudioSoundEffectInstance(device, nativeSoundEffect as XAudioSoundEffect);
|
return new XAudioSoundEffectInstance(device, nativeSoundEffect as XAudioSoundEffect);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -154,46 +178,47 @@ namespace ANX.SoundSystem.Windows.XAudio
|
|||||||
#region CreateDynamicSoundEffectInstance
|
#region CreateDynamicSoundEffectInstance
|
||||||
public IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance(int sampleRate, AudioChannels channels)
|
public IDynamicSoundEffectInstance CreateDynamicSoundEffectInstance(int sampleRate, AudioChannels channels)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
return new XAudioDynamicSoundEffectInstance(device, sampleRate, channels);
|
return new XAudioDynamicSoundEffectInstance(device, sampleRate, channels);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public IMicrophone CreateMicrophone(Microphone managedMicrophone)
|
public IMicrophone CreateMicrophone(Microphone managedMicrophone)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyCollection<Microphone> GetAllMicrophones()
|
public ReadOnlyCollection<Microphone> GetAllMicrophones()
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDefaultMicrophone(ReadOnlyCollection<Microphone> allMicrophones)
|
public int GetDefaultMicrophone(ReadOnlyCollection<Microphone> allMicrophones)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region CreateSong
|
#region CreateSong
|
||||||
public ISong CreateSong(Song parentSong, Uri uri)
|
public ISong CreateSong(Song parentSong, Uri uri)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
return new XAudioSong(device, uri);
|
return new XAudioSong(device, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISong CreateSong(Song parentSong, string filepath, int duration)
|
public ISong CreateSong(Song parentSong, string filepath, int duration)
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
InitializeDevice();
|
||||||
|
|
||||||
return new XAudioSong(device, filepath, duration);
|
return new XAudioSong(device, filepath, duration);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static void PreventSystemChange()
|
|
||||||
{
|
|
||||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.SoundSystem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("ANX.Framework Team")]
|
[assembly: AssemblyCompany("ANX.Framework Team")]
|
||||||
[assembly: AssemblyProduct("ANX.SoundSystem.Windows.XAudio")]
|
[assembly: AssemblyProduct("ANX.SoundSystem.Windows.XAudio")]
|
||||||
[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")]
|
[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011 - 2012")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.0.4.*")]
|
[assembly: AssemblyVersion("0.4.1.*")]
|
||||||
[assembly: AssemblyFileVersion("0.0.4.0")]
|
[assembly: AssemblyFileVersion("0.4.1.0")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user