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
This commit is contained in:
Sean Fausett 2010-04-04 04:25:28 +00:00
parent 7b713e6aaa
commit 5f8c4ce9d8
11 changed files with 46 additions and 112 deletions

View File

@ -11,9 +11,9 @@ using Jellyfish.Library;
[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)]

View File

@ -11,9 +11,9 @@ using Jellyfish.Library;
[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)]

View File

@ -17,11 +17,11 @@ using Jellyfish.Library;
[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)]

View File

@ -48,38 +48,6 @@
<Namespaces>
<Namespace Name="Jellyfish.Virtu">
<Types>
<Type Name="DiskDsk">
<Members>
<Member Name="#Read3Nibbles(System.Byte,System.Byte,System.Byte,System.Int32)">
<Messages>
<Message Id="nibble" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.Read3Nibbles(byte, byte, byte, int)'</Item>
<Item>'nibble'</Item>
<Item>'byte'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#WriteTrack(System.Int32,System.Int32,System.Byte[])">
<Messages>
<Message TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201" Created="2009-12-11 09:07:49Z">
<Issue Name="TooGeneric">
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'Exception'</Item>
</Issue>
</Message>
<Message Id="readVolume" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'readVolume'</Item>
<Item>'int'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="MainWindow">
<Members>
<Member Name="#System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object)">
@ -102,61 +70,11 @@
</Module>
</Modules>
</Target>
<Target Name="$(ProjectDir)/Xna/bin/Jellyfish.Virtu.exe">
<Modules>
<Module Name="jellyfish.virtu.exe">
<Namespaces>
<Namespace Name="Jellyfish.Virtu">
<Types>
<Type Name="DiskDsk">
<Members>
<Member Name="#Read3Nibbles(System.Byte,System.Byte,System.Byte,System.Int32)">
<Messages>
<Message Id="nibble" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.Read3Nibbles(byte, byte, byte, int)'</Item>
<Item>'nibble'</Item>
<Item>'byte'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#WriteTrack(System.Int32,System.Int32,System.Byte[])">
<Messages>
<Message TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201" Created="2009-12-11 09:07:49Z">
<Issue Name="TooGeneric">
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'Exception'</Item>
</Issue>
</Message>
<Message Id="readVolume" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'readVolume'</Item>
<Item>'int'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
</Types>
</Namespace>
</Namespaces>
</Module>
</Modules>
</Target>
</Targets>
<Rules>
<Rule TypeName="DoNotCastUnnecessarily" Category="Microsoft.Performance" CheckId="CA1800">
<Resolution Name="Parameter">{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.</Resolution>
</Rule>
<Rule TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201">
<Resolution Name="TooGeneric">{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.</Resolution>
</Rule>
<Rule TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804">
<Resolution Name="Default">{0} declares a variable, {1}, of type {2}, which is never used or is only assigned to. Use this variable or remove it.</Resolution>
</Rule>
</Rules>
</FxCopReport>
</FxCopProject>

View File

@ -304,6 +304,7 @@ namespace Jellyfish.Virtu.Settings
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";
}

View File

@ -37,16 +37,14 @@ namespace Jellyfish.Virtu.Services
protected void Update(int bufferSize, Action<byte[], int> 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();
}

View File

@ -11,9 +11,9 @@ using Jellyfish.Library;
[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)]

View File

@ -12,9 +12,9 @@ using Jellyfish.Library;
[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)]

View File

@ -15,11 +15,7 @@ namespace Jellyfish.Virtu
_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);

View File

@ -15,11 +15,11 @@ using Jellyfish.Library;
[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)]

View File

@ -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 @@ namespace Jellyfish.Virtu.Services
_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
}
}