mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-06-02 12:41:31 +00:00
ea2a892113
Modified CPU throttling to sync with audio thread. Added CPU multiplier to machine settings. Bumped version to 0.8 for next release. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4043066
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
|
using System.Windows.Controls;
|
|
using Jellyfish.Library;
|
|
|
|
namespace Jellyfish.Virtu.Services
|
|
{
|
|
public sealed class SilverlightAudioService : AudioService
|
|
{
|
|
public SilverlightAudioService(Machine machine, UserControl page, MediaElement media) :
|
|
base(machine)
|
|
{
|
|
if (page == null)
|
|
{
|
|
throw new ArgumentNullException("page");
|
|
}
|
|
if (media == null)
|
|
{
|
|
throw new ArgumentNullException("media");
|
|
}
|
|
|
|
_page = page;
|
|
_media = media;
|
|
|
|
_page.Loaded += (sender, e) => { _media.SetSource(_mediaSource); _media.Play(); };
|
|
_mediaSource.Update += OnMediaSourceUpdate;
|
|
//_page.Closed += (sender, e) => _media.Stop(); // SL is missing Closed / Unloaded event
|
|
}
|
|
|
|
private void OnMediaSourceUpdate(object sender, WaveMediaStreamSourceUpdateEventArgs e)
|
|
{
|
|
Update(e.BufferSize, (source, count) =>
|
|
{
|
|
Buffer.BlockCopy(source, 0, e.Buffer, 0, count);
|
|
});
|
|
}
|
|
|
|
private UserControl _page;
|
|
private MediaElement _media;
|
|
private WaveMediaStreamSource _mediaSource = new WaveMediaStreamSource(SampleRate, SampleChannels, SampleBits, SampleSize, SampleLatency);
|
|
}
|
|
}
|