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:
Sean Fausett 2010-08-22 11:04:52 +00:00
parent bf2c8e9b43
commit 5485e01e02
3 changed files with 48 additions and 7 deletions

View File

@ -29,9 +29,12 @@ namespace Jellyfish.Library
public void SetVolume(double volume)
{
int attenuation = (volume < 0.01) ? (int)BufferVolume.Min : (int)Math.Floor(100 * 20 * Math.Log10(volume)); // 100 db
if (_buffer != null)
lock (_bufferLock)
{
_buffer.SetVolume(attenuation);
if (_buffer != null)
{
_buffer.SetVolume(attenuation);
}
}
}
@ -116,11 +119,14 @@ namespace Jellyfish.Library
private void Uninitialize()
{
if (_buffer != null)
lock (_bufferLock)
{
_buffer.Stop();
Marshal.ReleaseComObject(_buffer);
_buffer = null;
if (_buffer != null)
{
_buffer.Stop();
Marshal.ReleaseComObject(_buffer);
_buffer = null;
}
}
if (_device != null)
{
@ -157,6 +163,7 @@ namespace Jellyfish.Library
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);

View File

@ -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 @@ namespace Jellyfish.Library
//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 @@ namespace Jellyfish.Library
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);

View File

@ -8,6 +8,7 @@ namespace Jellyfish.Virtu
base("Virtu")
{
InitializeComponent();
InitializeOutOfBrowserUpdate();
}
}
}