Updated the build system, now using .NET Framework v4.0 for most things

This commit is contained in:
Grigory Chudov
2018-03-11 17:07:48 -04:00
parent a66bfe28cc
commit 929b7de944
905 changed files with 13647 additions and 216371 deletions

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5A9FB016-6388-475D-AB33-6F86AD49FDAD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CUETools.Codecs.DirectSound</RootNamespace>
<AssemblyName>CUETools.Codecs.DirectSound</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug\net40\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\net40\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.DirectX.DirectSound, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DirectSoundOut.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
<Project>{6458A13A-30EF-45A9-9D58-E5031B17BEE2}</Project>
<Name>CUETools.Codecs</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,297 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectSound;
namespace CUETools.Codecs.DirectSound
{
public class DirectSoundOut : IWavePlayer
{
private Device dSound;
private WaveFormat format;// = new WaveFormat();
private BufferDescription description = new BufferDescription();
private SecondaryBuffer secondaryBuffer;
private Notify notify;
private MemoryStream pcmStream;
private int SecBufByteSize;
private AudioEncoderSettings m_settings;
PlaybackState playbackState = PlaybackState.Stopped;
/// <summary>
/// Playback Stopped
/// </summary>
public event EventHandler PlaybackStopped;
AutoResetEvent
SecBufNotifyAtBegin = new AutoResetEvent(false),
SecBufNotifyAtOneThird = new AutoResetEvent(false),
SecBufNotifyAtTwoThirds = new AutoResetEvent(false);
WaitHandle[] SecBufWaitHandles;
public DirectSoundOut(Control owner, AudioPCMConfig pcm, int delay)
{
this.m_settings = new AudioEncoderSettings(pcm);
//buffer = new CyclicBuffer(44100*4/10);
//output = new CycilcBufferOutputStream(buffer);
//input = new CycilcBufferInputStream(buffer);
dSound = new Device();
dSound.SetCooperativeLevel(owner, CooperativeLevel.Priority);
format.AverageBytesPerSecond = pcm.SampleRate * pcm.BlockAlign;
format.BitsPerSample = (short)pcm.BitsPerSample;
format.BlockAlign = (short)pcm.BlockAlign;
format.Channels = (short)pcm.ChannelCount;
format.SamplesPerSecond = pcm.SampleRate;
format.FormatTag = WaveFormatTag.Pcm;
SecBufByteSize = delay * pcm.SampleRate * pcm.BlockAlign / 1000;
description.Format = format;
description.BufferBytes = SecBufByteSize;
description.CanGetCurrentPosition = true;
description.ControlPositionNotify = true;
//description.ControlVolume = true;
description.GlobalFocus = true;
secondaryBuffer = new SecondaryBuffer(description, dSound);
//secondaryBuffer.Volume = 100;
notify = new Notify(secondaryBuffer);
BufferPositionNotify[] bufferPositions = new BufferPositionNotify[3];
bufferPositions[0].Offset = 0;
bufferPositions[0].EventNotifyHandle = SecBufNotifyAtBegin.Handle;
bufferPositions[1].Offset = SecBufByteSize / 3;
bufferPositions[1].EventNotifyHandle = SecBufNotifyAtOneThird.Handle;
bufferPositions[2].Offset = 2 * SecBufByteSize / 3;
bufferPositions[2].EventNotifyHandle = SecBufNotifyAtTwoThirds.Handle;
notify.SetNotificationPositions(bufferPositions);
pcmStream = new MemoryStream(SecBufByteSize);
SecBufWaitHandles = new WaitHandle[] { SecBufNotifyAtBegin, SecBufNotifyAtOneThird, SecBufNotifyAtTwoThirds };
//wavoutput = new WAVWriter("", output, pcm);
}
/// <summary>
/// Volume
/// </summary>
public float Volume
{
get
{
return 1.0f;
}
set
{
if (value != 1.0f)
{
throw new NotImplementedException();
}
}
}
//int SecBufNextWritePosition = 0;
//bool SecBufInitialLoad = false;
bool playing = false;
public void Write(AudioBuffer src)
{
//wavoutput.Write(src);
pcmStream.SetLength(0);
pcmStream.Write(src.Bytes, 0, src.ByteLength);
pcmStream.Position = 0;
//pcmStream.Position = 0;
//while (true)
//{
// if (SecBufInitialLoad)
// {
// int count = Math.Min(src.ByteLength, SecBufByteSize - SecBufNextWritePosition);
// if (count > 0)
// {
// secondaryBuffer.Write(SecBufNextWritePosition, pcmStream, count, LockFlag.None);
// SecBufNextWritePosition += count;
// pcmStream.Position += count;
// }
// if (SecBufByteSize == SecBufNextWritePosition)
// {
// // Finished filling the buffer
// SecBufInitialLoad = false;
// SecBufNextWritePosition = 0;
// // So start the playback in its own thread
// secondaryBuffer.Play(0, BufferPlayFlags.Looping);
// // Yield rest of timeslice so playback can
// // start right away.
// Thread.Sleep(0);
// }
// else
// {
// continue; // Get more PCM data
// }
// }
// Exhaust the current PCM data by writing the data into secondaryBuffer
while (pcmStream.Position < pcmStream.Length)
{
int PlayPosition, WritePosition;
secondaryBuffer.GetCurrentPosition(out PlayPosition, out WritePosition);
int WriteCount = (int)Math.Min(
(SecBufByteSize + PlayPosition - WritePosition) % SecBufByteSize,
pcmStream.Length - pcmStream.Position);
if (WriteCount > 0)
{
secondaryBuffer.Write(
WritePosition,
pcmStream,
WriteCount,
LockFlag.None);
pcmStream.Position += WriteCount;
if (!playing)
{
secondaryBuffer.Play(0, 0);
playing = true;
}
}
else
{
WaitHandle.WaitAny(SecBufWaitHandles, new TimeSpan(0, 0, 5), true);
}
}
}
/// <summary>
/// Begin Playback
/// </summary>
public void Play()
{
switch (playbackState)
{
case PlaybackState.Playing:
return;
case PlaybackState.Paused:
playbackState = PlaybackState.Playing;
return;
case PlaybackState.Stopped:
playbackState = PlaybackState.Playing;
//playThread = new Thread(new ThreadStart(PlayThread));
//playThread.Priority = ThreadPriority.Highest;
//playThread.IsBackground = true;
//playThread.Name = "Pro Audio";
//playThread.Start();
return;
}
}
/// <summary>
/// Stop playback and flush buffers
/// </summary>
public void Stop()
{
if (playbackState != PlaybackState.Stopped)
{
playbackState = PlaybackState.Stopped;
//if (frameEventWaitHandle != null)
// frameEventWaitHandle.Set();
//playThread.Join();
//playThread = null;
//ReleaseBuffer(readBuffers[0], false, 0);
//ReleaseBuffer(readBuffers[1], false, 0);
//active = null;
//active_offset = 0;
}
}
/// <summary>
/// Stop playback without flushing buffers
/// </summary>
public void Pause()
{
if (playbackState == PlaybackState.Playing)
{
playbackState = PlaybackState.Paused;
}
//if (frameEventWaitHandle != null)
// frameEventWaitHandle.Set();
}
/// <summary>
/// Playback State
/// </summary>
public PlaybackState PlaybackState
{
get { return playbackState; }
}
public void Close()
{
if (secondaryBuffer != null)
{
secondaryBuffer.Dispose();
secondaryBuffer = null;
}
if (dSound != null)
{
dSound.Dispose();
dSound = null;
}
//wavoutput.Close();
}
public void Delete()
{
Close();
}
#region IAudioDest Members
public long Position
{
get
{
return 0;
}
}
public long FinalSampleCount
{
set { ; }
}
public object Settings
{
get
{
return m_settings;
}
}
public string Path { get { return null; } }
#endregion
#region IDisposable Members
/// <summary>
/// Dispose
/// </summary>
public void Dispose()
{
//if (audioClient != null)
{
Stop();
}
}
#endregion
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CUETools.Codecs.DirectSound")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CUETools.Codecs.DirectSound")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("605f368f-e26a-4421-963d-c025b0cbd79e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]