From 5f8c4ce9d80b956ba1dbc750989ea5276ac6550e Mon Sep 17 00:00:00 2001 From: Sean Fausett Date: Sun, 4 Apr 2010 04:25:28 +0000 Subject: [PATCH] Worked around lack of audio on XNA+XBox360 blocking machine thread. Bumped version to 0.8.1 for next release. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4044502 --- .../Silverlight/Properties/AssemblyInfo.cs | 6 +- Library/Wpf/Properties/AssemblyInfo.cs | 6 +- Library/Xna/Properties/AssemblyInfo.cs | 6 +- Virtu/Jellyfish.Virtu.FxCop | 82 ------------------- Virtu/MachineSettings.cs | 1 + Virtu/Services/AudioService.cs | 10 +-- Virtu/Silverlight/Properties/AssemblyInfo.cs | 6 +- Virtu/Wpf/Properties/AssemblyInfo.cs | 6 +- Virtu/Xna/MainGame.cs | 4 - Virtu/Xna/Properties/AssemblyInfo.cs | 6 +- Virtu/Xna/Services/XnaAudioService.cs | 25 +++++- 11 files changed, 46 insertions(+), 112 deletions(-) diff --git a/Library/Silverlight/Properties/AssemblyInfo.cs b/Library/Silverlight/Properties/AssemblyInfo.cs index fdac8bc..e120db0 100644 --- a/Library/Silverlight/Properties/AssemblyInfo.cs +++ b/Library/Silverlight/Properties/AssemblyInfo.cs @@ -11,9 +11,9 @@ [assembly: AssemblyCopyright("Copyright © 2009-2010 Digital Jellyfish Design Ltd")] [assembly: AssemblyComment("Developed by Sean Fausett")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] -[assembly: AssemblyInformationalVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")] +[assembly: AssemblyInformationalVersion("0.1.1.0")] [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] diff --git a/Library/Wpf/Properties/AssemblyInfo.cs b/Library/Wpf/Properties/AssemblyInfo.cs index f0d9ae0..207d308 100644 --- a/Library/Wpf/Properties/AssemblyInfo.cs +++ b/Library/Wpf/Properties/AssemblyInfo.cs @@ -11,9 +11,9 @@ [assembly: AssemblyCopyright("Copyright © 2009-2010 Digital Jellyfish Design Ltd")] [assembly: AssemblyComment("Developed by Sean Fausett")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] -[assembly: AssemblyInformationalVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")] +[assembly: AssemblyInformationalVersion("0.1.1.0")] [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] diff --git a/Library/Xna/Properties/AssemblyInfo.cs b/Library/Xna/Properties/AssemblyInfo.cs index 0a8ffc6..722b9f7 100644 --- a/Library/Xna/Properties/AssemblyInfo.cs +++ b/Library/Xna/Properties/AssemblyInfo.cs @@ -17,11 +17,11 @@ [assembly: AssemblyCopyright("Copyright © 2009-2010 Digital Jellyfish Design Ltd")] [assembly: AssemblyComment("Developed by Sean Fausett")] -[assembly: AssemblyVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] #if WINDOWS -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyFileVersion("0.1.1.0")] #endif -[assembly: AssemblyInformationalVersion("0.1.0.0")] +[assembly: AssemblyInformationalVersion("0.1.1.0")] [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] diff --git a/Virtu/Jellyfish.Virtu.FxCop b/Virtu/Jellyfish.Virtu.FxCop index 9189152..6288a3e 100644 --- a/Virtu/Jellyfish.Virtu.FxCop +++ b/Virtu/Jellyfish.Virtu.FxCop @@ -48,38 +48,6 @@ - - - - - - - 'DiskDsk.Read3Nibbles(byte, byte, byte, int)' - 'nibble' - 'byte' - - - - - - - - - 'DiskDsk.WriteTrack(int, int, byte[])' - 'Exception' - - - - - 'DiskDsk.WriteTrack(int, int, byte[])' - 'readVolume' - 'int' - - - - - - @@ -102,61 +70,11 @@ - - - - - - - - - - - - - 'DiskDsk.Read3Nibbles(byte, byte, byte, int)' - 'nibble' - 'byte' - - - - - - - - - 'DiskDsk.WriteTrack(int, int, byte[])' - 'Exception' - - - - - 'DiskDsk.WriteTrack(int, int, byte[])' - 'readVolume' - 'int' - - - - - - - - - - - - {0}, a parameter, is cast to type {1} multiple times in method {2}. Cache the result of the 'as' operator or direct cast in order to eliminate the redundant {3} instruction. - - {0} creates an exception of type {1}, an exception type that is not sufficiently specific and should never be raised by user code. If this exception instance might be thrown, use a different exception type. - - - {0} declares a variable, {1}, of type {2}, which is never used or is only assigned to. Use this variable or remove it. - diff --git a/Virtu/MachineSettings.cs b/Virtu/MachineSettings.cs index f0ef767..b78daf4 100644 --- a/Virtu/MachineSettings.cs +++ b/Virtu/MachineSettings.cs @@ -304,6 +304,7 @@ public void Serialize(Stream stream) public VideoSettings Video { get; set; } public const string FileName = "Settings.xml"; + [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] public static readonly XNamespace Namespace = "http://schemas.jellyfish.co.nz/virtu/settings"; } diff --git a/Virtu/Services/AudioService.cs b/Virtu/Services/AudioService.cs index 10595c7..df454fe 100644 --- a/Virtu/Services/AudioService.cs +++ b/Virtu/Services/AudioService.cs @@ -37,16 +37,14 @@ public override void Stop() // main thread protected void Update(int bufferSize, Action updateBuffer) // audio thread { - if (updateBuffer == null) - { - throw new ArgumentNullException("updateBuffer"); - } - if (Machine.State == MachineState.Running) { _readEvent.WaitOne(); } - updateBuffer(_buffer, bufferSize); + if (updateBuffer != null) + { + updateBuffer(_buffer, bufferSize); + } _writeEvent.Set(); } diff --git a/Virtu/Silverlight/Properties/AssemblyInfo.cs b/Virtu/Silverlight/Properties/AssemblyInfo.cs index af27079..a107935 100644 --- a/Virtu/Silverlight/Properties/AssemblyInfo.cs +++ b/Virtu/Silverlight/Properties/AssemblyInfo.cs @@ -11,9 +11,9 @@ [assembly: AssemblyCopyright("Copyright © 1995-2010 Digital Jellyfish Design Ltd")] [assembly: AssemblyComment("Developed by Sean Fausett & Nick Westgate")] -[assembly: AssemblyVersion("0.8.0.0")] -[assembly: AssemblyFileVersion("0.8.0.0")] -[assembly: AssemblyInformationalVersion("0.8.0.0")] +[assembly: AssemblyVersion("0.8.1.0")] +[assembly: AssemblyFileVersion("0.8.1.0")] +[assembly: AssemblyInformationalVersion("0.8.1.0")] [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] diff --git a/Virtu/Wpf/Properties/AssemblyInfo.cs b/Virtu/Wpf/Properties/AssemblyInfo.cs index e6f08c4..5476c0c 100644 --- a/Virtu/Wpf/Properties/AssemblyInfo.cs +++ b/Virtu/Wpf/Properties/AssemblyInfo.cs @@ -12,9 +12,9 @@ [assembly: AssemblyCopyright("Copyright © 1995-2010 Digital Jellyfish Design Ltd")] [assembly: AssemblyComment("Developed by Sean Fausett & Nick Westgate")] -[assembly: AssemblyVersion("0.8.0.0")] -[assembly: AssemblyFileVersion("0.8.0.0")] -[assembly: AssemblyInformationalVersion("0.8.0.0")] +[assembly: AssemblyVersion("0.8.1.0")] +[assembly: AssemblyFileVersion("0.8.1.0")] +[assembly: AssemblyInformationalVersion("0.8.1.0")] [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] diff --git a/Virtu/Xna/MainGame.cs b/Virtu/Xna/MainGame.cs index d1cb033..8f71185 100644 --- a/Virtu/Xna/MainGame.cs +++ b/Virtu/Xna/MainGame.cs @@ -15,11 +15,7 @@ public MainGame() : _storageService = new XnaStorageService(_machine, this); _keyboardService = new XnaKeyboardService(_machine); _gamePortService = new XnaGamePortService(_machine); -#if XBOX - _audioService = new AudioService(_machine); // not connected -#else _audioService = new XnaAudioService(_machine, this); -#endif _videoService = new XnaVideoService(_machine, this); _machine.Services.AddService(typeof(StorageService), _storageService); diff --git a/Virtu/Xna/Properties/AssemblyInfo.cs b/Virtu/Xna/Properties/AssemblyInfo.cs index 405c466..6a136e2 100644 --- a/Virtu/Xna/Properties/AssemblyInfo.cs +++ b/Virtu/Xna/Properties/AssemblyInfo.cs @@ -15,11 +15,11 @@ [assembly: AssemblyCopyright("Copyright © 1995-2010 Digital Jellyfish Design Ltd")] [assembly: AssemblyComment("Developed by Sean Fausett & Nick Westgate")] -[assembly: AssemblyVersion("0.8.0.0")] +[assembly: AssemblyVersion("0.8.1.0")] #if WINDOWS -[assembly: AssemblyFileVersion("0.8.0.0")] +[assembly: AssemblyFileVersion("0.8.1.0")] #endif -[assembly: AssemblyInformationalVersion("0.8.0.0")] +[assembly: AssemblyInformationalVersion("0.8.1.0")] [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] diff --git a/Virtu/Xna/Services/XnaAudioService.cs b/Virtu/Xna/Services/XnaAudioService.cs index 3e11e82..a1959f9 100644 --- a/Virtu/Xna/Services/XnaAudioService.cs +++ b/Virtu/Xna/Services/XnaAudioService.cs @@ -1,12 +1,14 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; +using System.Threading; using Jellyfish.Library; namespace Jellyfish.Virtu.Services { -#if WINDOWS public sealed class XnaAudioService : AudioService { + [SuppressMessage("Microsoft.Mobility", "CA1601:DoNotUseTimersThatPreventPowerStateChanges")] public XnaAudioService(Machine machine, GameBase game) : base(machine) { @@ -17,26 +19,45 @@ public XnaAudioService(Machine machine, GameBase game) : _game = game; +#if WINDOWS _directSound.Start(_game.Window.Handle); _directSound.Update += OnDirectSoundUpdate; _game.Exiting += (sender, e) => _directSound.Stop(); +#else + _timer = new Timer(OnTimerUpdate, null, 0, SampleLatency); + _game.Exiting += (sender, e) => _timer.Change(Timeout.Infinite, Timeout.Infinite); +#endif } protected override void Dispose(bool disposing) { if (disposing) { +#if WINDOWS _directSound.Dispose(); +#else + _timer.Dispose(); +#endif } } +#if WINDOWS private void OnDirectSoundUpdate(object sender, DirectSoundUpdateEventArgs e) // audio thread { Update(e.BufferSize, (source, count) => Marshal.Copy(source, 0, e.Buffer, count)); } +#else + private void OnTimerUpdate(object state) // audio thread + { + Update(0, null); + } +#endif private GameBase _game; +#if WINDOWS private DirectSound _directSound = new DirectSound(SampleRate, SampleChannels, SampleBits, SampleSize); - } +#else + private Timer _timer; #endif + } }