mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-11-23 19:30:59 +00:00
Added ApplicationBase.InitializeOutOfBrowserUpdate to Silverlight library.
Fixed race condition in DirectSound wrapper; between SetVolume and Uninitialize. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4050691
This commit is contained in:
parent
bf2c8e9b43
commit
5485e01e02
@ -29,11 +29,14 @@ public void Dispose()
|
||||
public void SetVolume(double volume)
|
||||
{
|
||||
int attenuation = (volume < 0.01) ? (int)BufferVolume.Min : (int)Math.Floor(100 * 20 * Math.Log10(volume)); // 100 db
|
||||
lock (_bufferLock)
|
||||
{
|
||||
if (_buffer != null)
|
||||
{
|
||||
_buffer.SetVolume(attenuation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Start(IntPtr window)
|
||||
{
|
||||
@ -115,6 +118,8 @@ private void UpdateBuffer(int offset, int count, BufferLock flags, Action<IntPtr
|
||||
}
|
||||
|
||||
private void Uninitialize()
|
||||
{
|
||||
lock (_bufferLock)
|
||||
{
|
||||
if (_buffer != null)
|
||||
{
|
||||
@ -122,6 +127,7 @@ private void Uninitialize()
|
||||
Marshal.ReleaseComObject(_buffer);
|
||||
_buffer = null;
|
||||
}
|
||||
}
|
||||
if (_device != null)
|
||||
{
|
||||
Marshal.ReleaseComObject(_device);
|
||||
@ -157,6 +163,7 @@ private void Run() // com mta thread
|
||||
private IntPtr _window;
|
||||
private IDirectSound _device;
|
||||
private IDirectSoundBuffer _buffer;
|
||||
private object _bufferLock = new object();
|
||||
private Action<IntPtr, int> _updater;
|
||||
|
||||
private AutoResetEvent _position1Event = new AutoResetEvent(false);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
#if WINDOWS_PHONE
|
||||
@ -24,6 +25,17 @@ public ApplicationBase(string name)
|
||||
//AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnhandledException;
|
||||
}
|
||||
|
||||
#if !WINDOWS_PHONE
|
||||
protected void InitializeOutOfBrowserUpdate()
|
||||
{
|
||||
if (IsRunningOutOfBrowser)
|
||||
{
|
||||
CheckAndDownloadUpdateCompleted += OnApplicationCheckAndDownloadUpdateCompleted;
|
||||
CheckAndDownloadUpdateAsync();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WINDOWS_PHONE
|
||||
protected void InitializePhoneApplication()
|
||||
{
|
||||
@ -53,6 +65,27 @@ private string GetExceptionCaption(string title, bool isTerminating = false)
|
||||
return caption.ToString();
|
||||
}
|
||||
|
||||
#if !WINDOWS_PHONE
|
||||
private void OnApplicationCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
|
||||
{
|
||||
if (e.Error != null)
|
||||
{
|
||||
if (e.Error is PlatformNotSupportedException)
|
||||
{
|
||||
MessageBox.Show("An application update is available, but it requires the latest version of Silverlight.");
|
||||
}
|
||||
else if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
else if (e.UpdateAvailable)
|
||||
{
|
||||
MessageBox.Show("An application update was downloaded. Restart the application to run the latest version.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void OnApplicationUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
MessageBox.Show(e.ExceptionObject.ToString(), GetExceptionCaption("Application Exception"), MessageBoxButton.OK);
|
||||
|
@ -8,6 +8,7 @@ public MainApp() :
|
||||
base("Virtu")
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeOutOfBrowserUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user