mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-06-12 01:29:27 +00:00
ae126d2552
Implemented video scanner and floating bus. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4035682
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Jellyfish.Library;
|
|
|
|
namespace Jellyfish.Virtu.Services
|
|
{
|
|
#if WINDOWS
|
|
public sealed class XnaAudioService : AudioService
|
|
{
|
|
public XnaAudioService(Machine machine, GameBase game) :
|
|
base(machine)
|
|
{
|
|
if (game == null)
|
|
{
|
|
throw new ArgumentNullException("game");
|
|
}
|
|
|
|
_game = game;
|
|
|
|
_directSound.Start(_game.Window.Handle);
|
|
_directSound.Update += OnDirectSoundUpdate;
|
|
_game.Exiting += (sender, e) => _directSound.Stop();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
_directSound.Dispose();
|
|
}
|
|
}
|
|
|
|
private void OnDirectSoundUpdate(object sender, DirectSoundUpdateEventArgs e)
|
|
{
|
|
IntPtr buffer = e.Buffer;
|
|
Update(e.BufferSize, (source, count) =>
|
|
{
|
|
Marshal.Copy(source, 0, buffer, count);
|
|
buffer = (IntPtr)((long)buffer + count);
|
|
});
|
|
}
|
|
|
|
private GameBase _game;
|
|
private DirectSound _directSound = new DirectSound(SampleRate, SampleChannels, SampleBits, SampleSize);
|
|
}
|
|
#endif
|
|
}
|