mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Add project files.
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.RenderAPI.Audio.SoundData
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Data;
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.RenderAPI.Audio
|
||||
{
|
||||
internal class SoundData : ISoundData, IDisposable
|
||||
{
|
||||
private string _stSource;
|
||||
private Resource _soundResource;
|
||||
private uint _openCount;
|
||||
private bool _fStreamLoading;
|
||||
private bool _fStreamAvailable;
|
||||
private ExtensionsApi.HSpSound _soundHandle;
|
||||
private ExtensionsApi.SoundInformation _soundInfo;
|
||||
|
||||
internal SoundData(string stSource, Resource soundResource)
|
||||
{
|
||||
_stSource = stSource;
|
||||
_soundResource = soundResource;
|
||||
_fStreamAvailable = false;
|
||||
_fStreamLoading = false;
|
||||
}
|
||||
|
||||
~SoundData() => Dispose(false);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool fInDispose)
|
||||
{
|
||||
int num = fInDispose ? 1 : 0;
|
||||
if (!(_soundHandle != ExtensionsApi.HSpSound.NULL))
|
||||
return;
|
||||
SoundLoader.DisposeData(_soundHandle, _soundInfo);
|
||||
_soundHandle = ExtensionsApi.HSpSound.NULL;
|
||||
}
|
||||
|
||||
internal bool IsAvailable => _soundHandle != ExtensionsApi.HSpSound.NULL;
|
||||
|
||||
public bool Load()
|
||||
{
|
||||
bool flag = false;
|
||||
if (_openCount == 0U && !_fStreamAvailable && !_fStreamLoading)
|
||||
{
|
||||
_fStreamLoading = true;
|
||||
_soundResource.Acquire(new ResourceAcquisitionCompleteHandler(OnContentLoadComplete));
|
||||
}
|
||||
if (_soundHandle != ExtensionsApi.HSpSound.NULL)
|
||||
flag = true;
|
||||
else if (_fStreamAvailable)
|
||||
{
|
||||
if (_soundResource.Status == ResourceStatus.Available)
|
||||
{
|
||||
ExtensionsApi.HSpSound soundDataHandle;
|
||||
ExtensionsApi.SoundInformation soundDataInfo;
|
||||
SoundLoader.FromMemory(_soundResource.Buffer, (int)_soundResource.Length, out soundDataHandle, out soundDataInfo);
|
||||
_soundHandle = soundDataHandle;
|
||||
_soundInfo = soundDataInfo;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
flag = false;
|
||||
++_openCount;
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
--_openCount;
|
||||
if (_openCount != 0U)
|
||||
return;
|
||||
if (_fStreamAvailable)
|
||||
{
|
||||
_soundResource.Free(new ResourceAcquisitionCompleteHandler(OnContentLoadComplete));
|
||||
_fStreamAvailable = false;
|
||||
}
|
||||
if (!(_soundHandle != ExtensionsApi.HSpSound.NULL))
|
||||
return;
|
||||
SoundLoader.DisposeData(_soundHandle, _soundInfo);
|
||||
_soundHandle = ExtensionsApi.HSpSound.NULL;
|
||||
}
|
||||
|
||||
public static string GetCacheKey(string stSource) => InvariantString.Format("SND|{0}", stSource);
|
||||
|
||||
SoundDataFormat ISoundData.Format => (SoundDataFormat)_soundInfo.Header.wFormatTag;
|
||||
|
||||
uint ISoundData.ChannelCount => _soundInfo.Header.nChannels;
|
||||
|
||||
uint ISoundData.SampleRate => _soundInfo.Header.nSamplesPerSec;
|
||||
|
||||
uint ISoundData.SampleSize => _soundInfo.Header.wBitsPerSample;
|
||||
|
||||
uint ISoundData.SampleCount => _soundInfo.Header.cbDataSize * 8U / _soundInfo.Header.wBitsPerSample;
|
||||
|
||||
IntPtr ISoundData.AcquireContent()
|
||||
{
|
||||
if (Load())
|
||||
return _soundInfo.Data.rgData;
|
||||
throw new InvalidOperationException("Sound data isn't available");
|
||||
}
|
||||
|
||||
void ISoundData.ReleaseContent() => Unload();
|
||||
|
||||
private void OnContentLoadComplete(Resource resource)
|
||||
{
|
||||
_fStreamLoading = false;
|
||||
if (_soundResource.Status == ResourceStatus.Error)
|
||||
_fStreamAvailable = false;
|
||||
else
|
||||
_fStreamAvailable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.RenderAPI.Audio.SoundManager
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Data;
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Session;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Iris.RenderAPI.Audio
|
||||
{
|
||||
internal class SoundManager : IDisposable
|
||||
{
|
||||
private UISession _uiSession;
|
||||
private IRenderSession _renderSession;
|
||||
private Dictionary<string, SoundManager.SoundContent> _dictContent;
|
||||
private SystemSoundEventTable _systemSoundEventTable;
|
||||
|
||||
internal SoundManager(UISession uiSession, IRenderSession renderSession)
|
||||
{
|
||||
_uiSession = uiSession;
|
||||
_renderSession = renderSession;
|
||||
_dictContent = new Dictionary<string, SoundManager.SoundContent>(InvariantString.OrdinalComparer);
|
||||
}
|
||||
|
||||
~SoundManager() => Dispose(false);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool fInDispose)
|
||||
{
|
||||
if (fInDispose && _dictContent != null)
|
||||
{
|
||||
foreach (SoundManager.SoundContent soundContent in _dictContent.Values)
|
||||
{
|
||||
if (soundContent.soundBuffer != null)
|
||||
soundContent.soundBuffer.UnregisterUsage(this);
|
||||
if (soundContent.soundData != null)
|
||||
{
|
||||
soundContent.soundData.Unload();
|
||||
soundContent.soundData.Dispose();
|
||||
}
|
||||
}
|
||||
_dictContent.Clear();
|
||||
}
|
||||
_dictContent = null;
|
||||
_renderSession = null;
|
||||
_uiSession = null;
|
||||
}
|
||||
|
||||
internal string GetSystemSoundEventSource(SystemSoundEvent systemSoundEvent)
|
||||
{
|
||||
if (_systemSoundEventTable == null)
|
||||
_systemSoundEventTable = new SystemSoundEventTable();
|
||||
string filePath = _systemSoundEventTable.GetFilePath(systemSoundEvent);
|
||||
return string.IsNullOrEmpty(filePath) ? null : string.Format("file://{0}", filePath);
|
||||
}
|
||||
|
||||
public void SetVolume(float flVolume)
|
||||
{
|
||||
if (_renderSession.SoundDevice == null)
|
||||
return;
|
||||
_renderSession.SoundDevice.Volume = flVolume;
|
||||
}
|
||||
|
||||
public void SetMute(bool fMute)
|
||||
{
|
||||
if (_renderSession.SoundDevice == null)
|
||||
return;
|
||||
_renderSession.SoundDevice.Mute = fMute;
|
||||
}
|
||||
|
||||
internal ISoundBuffer GetSoundBuffer(string source)
|
||||
{
|
||||
bool flag = false;
|
||||
string cacheKey = SoundData.GetCacheKey(source);
|
||||
SoundManager.SoundContent soundContent;
|
||||
if (!_dictContent.TryGetValue(cacheKey, out soundContent))
|
||||
{
|
||||
Resource resource = ResourceManager.Instance.GetResource(source);
|
||||
if (resource == null)
|
||||
return null;
|
||||
soundContent = new SoundManager.SoundContent();
|
||||
soundContent.soundData = new SoundData(cacheKey, resource);
|
||||
soundContent.soundData.Load();
|
||||
flag = true;
|
||||
}
|
||||
if (soundContent.soundBuffer == null && soundContent.soundData.IsAvailable && _renderSession.SoundDevice != null)
|
||||
soundContent.soundBuffer = _renderSession.SoundDevice.CreateSoundBuffer(this, soundContent.soundData);
|
||||
if (flag)
|
||||
_dictContent[cacheKey] = soundContent;
|
||||
return soundContent.soundBuffer;
|
||||
}
|
||||
|
||||
private class SoundContent
|
||||
{
|
||||
public SoundData soundData;
|
||||
public ISoundBuffer soundBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.RenderAPI.Audio.SystemSoundEvent
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace Microsoft.Iris.RenderAPI.Audio
|
||||
{
|
||||
internal enum SystemSoundEvent
|
||||
{
|
||||
None,
|
||||
Asterisk,
|
||||
CloseProgram,
|
||||
CriticalBatteryAlarm,
|
||||
CriticalStop,
|
||||
DefaultBeep,
|
||||
DeviceConnect,
|
||||
DeviceDisconnect,
|
||||
DeviceFailedToConnect,
|
||||
Exclamation,
|
||||
ExitWindows,
|
||||
LowBatteryAlarm,
|
||||
Maximize,
|
||||
MenuCommand,
|
||||
MenuPopup,
|
||||
Minimize,
|
||||
NewFaxNotification,
|
||||
NewMailNotification,
|
||||
OpenProgram,
|
||||
PrintComplete,
|
||||
ProgramError,
|
||||
Question,
|
||||
RestoreDown,
|
||||
RestoreUp,
|
||||
Select,
|
||||
ShowToolbarBand,
|
||||
StartWindows,
|
||||
SystemNotification,
|
||||
WindowsLogoff,
|
||||
WindowsLogon,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.RenderAPI.Audio.SystemSoundEventTable
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Debug;
|
||||
|
||||
namespace Microsoft.Iris.RenderAPI.Audio
|
||||
{
|
||||
internal class SystemSoundEventTable
|
||||
{
|
||||
private static readonly string s_RegistryParentKey = "AppEvents\\Schemes\\Apps\\.Default";
|
||||
private Map<SystemSoundEvent, SystemSoundEventTable.SystemSound> m_systemSoundDictionary;
|
||||
|
||||
public SystemSoundEventTable()
|
||||
{
|
||||
m_systemSoundDictionary = new Map<SystemSoundEvent, SystemSoundEventTable.SystemSound>();
|
||||
Add(SystemSoundEvent.Asterisk, "SystemAsterisk");
|
||||
Add(SystemSoundEvent.CloseProgram, "CloseProgram");
|
||||
Add(SystemSoundEvent.CriticalBatteryAlarm, "CriticalBatteryAlarm");
|
||||
Add(SystemSoundEvent.CriticalStop, "SystemHand");
|
||||
Add(SystemSoundEvent.DefaultBeep, ".Default");
|
||||
Add(SystemSoundEvent.DeviceConnect, "DeviceConnect");
|
||||
Add(SystemSoundEvent.DeviceDisconnect, "DeviceDisconnect");
|
||||
Add(SystemSoundEvent.DeviceFailedToConnect, "DeviceFail");
|
||||
Add(SystemSoundEvent.Exclamation, "SystemExclamation");
|
||||
Add(SystemSoundEvent.ExitWindows, "SystemExit");
|
||||
Add(SystemSoundEvent.LowBatteryAlarm, "LowBatteryAlarm");
|
||||
Add(SystemSoundEvent.Maximize, "Maximize");
|
||||
Add(SystemSoundEvent.MenuCommand, "MenuCommand");
|
||||
Add(SystemSoundEvent.MenuPopup, "MenuPopup");
|
||||
Add(SystemSoundEvent.Minimize, "Minimize");
|
||||
Add(SystemSoundEvent.NewFaxNotification, "FaxBeep");
|
||||
Add(SystemSoundEvent.NewMailNotification, "MailBeep");
|
||||
Add(SystemSoundEvent.OpenProgram, "Open");
|
||||
Add(SystemSoundEvent.PrintComplete, "PrintComplete");
|
||||
Add(SystemSoundEvent.ProgramError, "AppGPFault");
|
||||
Add(SystemSoundEvent.Question, "SystemQuestion");
|
||||
Add(SystemSoundEvent.RestoreDown, "RestoreDown");
|
||||
Add(SystemSoundEvent.RestoreUp, "RestoreUp");
|
||||
Add(SystemSoundEvent.Select, "CCSelect");
|
||||
Add(SystemSoundEvent.ShowToolbarBand, "ShowBand");
|
||||
Add(SystemSoundEvent.StartWindows, "SystemStart");
|
||||
Add(SystemSoundEvent.SystemNotification, "SystemNotification");
|
||||
Add(SystemSoundEvent.WindowsLogoff, "WindowsLogoff");
|
||||
Add(SystemSoundEvent.WindowsLogon, "WindowsLogon");
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
RegistryKey registryKey1 = RegistryKey.Open(RegistryKey.HKEY_CURRENT_USER, s_RegistryParentKey);
|
||||
if (registryKey1 == null)
|
||||
return;
|
||||
foreach (SystemSoundEventTable.SystemSound systemSound in m_systemSoundDictionary.Values)
|
||||
{
|
||||
RegistryKey registryKey2 = registryKey1.OpenSubKey(systemSound.RegistrySubKey + "\\.Current");
|
||||
if (registryKey2 != null)
|
||||
{
|
||||
registryKey2.ReadString(null, out systemSound.FilePath);
|
||||
registryKey2.Close();
|
||||
}
|
||||
}
|
||||
registryKey1.Close();
|
||||
}
|
||||
|
||||
public string GetFilePath(SystemSoundEvent systemSoundEvent) => m_systemSoundDictionary[systemSoundEvent].FilePath;
|
||||
|
||||
private void Add(SystemSoundEvent systemSoundEvent, string registrySubKey) => m_systemSoundDictionary.Add(systemSoundEvent, new SystemSoundEventTable.SystemSound()
|
||||
{
|
||||
Event = systemSoundEvent,
|
||||
RegistrySubKey = registrySubKey
|
||||
});
|
||||
|
||||
internal class SystemSound
|
||||
{
|
||||
public SystemSoundEvent Event;
|
||||
public string RegistrySubKey;
|
||||
public string FilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user