Skip to content

Commit b4685e1

Browse files
committed
#8 - New Vortice.Audio project and target .NET6.0 only for now.
1 parent 23d34a5 commit b4685e1

File tree

13 files changed

+164
-79
lines changed

13 files changed

+164
-79
lines changed

Diff for: Directory.Build.props

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
</PropertyGroup>
2727

2828
<PropertyGroup>
29+
<VorticeMathematicsVersion>1.4.0</VorticeMathematicsVersion>
2930
<VorticeVulkanVersion>1.4.7</VorticeVulkanVersion>
30-
<VorticeWindowsVersion>2.1.1-beta8</VorticeWindowsVersion>
31+
<VorticeWindowsVersion>2.1.1-beta9</VorticeWindowsVersion>
3132
</PropertyGroup>
3233

3334
<!-- platform version number information -->

Diff for: Vortice.sln

+10-24
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Platform.Windows",
2222
EndProject
2323
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Platform.SDL2", "src\Platforms\Vortice.Platform.SDL2\Vortice.Platform.SDL2.csproj", "{E7888A66-50C2-427D-9B47-5A924EB3A1DB}"
2424
EndProject
25-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Audio", "Audio", "{AE4FC02A-2DF0-4D1E-916E-8C1F3955C4A1}"
26-
EndProject
27-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Audio.OpenAL", "src\Audio\Vortice.Audio.OpenAL\Vortice.Audio.OpenAL.csproj", "{65E54210-5F02-45EE-96B1-C91816F7ACBD}"
28-
EndProject
29-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Audio.XAudio2", "src\Audio\Vortice.Audio.XAudio2\Vortice.Audio.XAudio2.csproj", "{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}"
30-
EndProject
3125
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Assets", "src\Vortice.Assets\Vortice.Assets.csproj", "{F6A4373B-0A3F-45F1-BA64-7AD30BB7F04C}"
3226
EndProject
3327
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{D8EC0278-B4F9-4EF5-A4BE-FE2284C6ECED}"
@@ -40,6 +34,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Samples.SDL2", "src
4034
EndProject
4135
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Graphics", "src\Vortice.Graphics\Vortice.Graphics.csproj", "{C2B70883-79CC-4216-886F-5F5EF0662924}"
4236
EndProject
37+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Audio", "src\Vortice.Audio\Vortice.Audio.csproj", "{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}"
38+
EndProject
4339
Global
4440
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4541
Debug|Any CPU = Debug|Any CPU
@@ -72,22 +68,6 @@ Global
7268
{E7888A66-50C2-427D-9B47-5A924EB3A1DB}.Release|Any CPU.Build.0 = Release|Any CPU
7369
{E7888A66-50C2-427D-9B47-5A924EB3A1DB}.Release|x64.ActiveCfg = Release|Any CPU
7470
{E7888A66-50C2-427D-9B47-5A924EB3A1DB}.Release|x64.Build.0 = Release|Any CPU
75-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
77-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Debug|x64.ActiveCfg = Debug|Any CPU
78-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Debug|x64.Build.0 = Debug|Any CPU
79-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
80-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Release|Any CPU.Build.0 = Release|Any CPU
81-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Release|x64.ActiveCfg = Release|Any CPU
82-
{65E54210-5F02-45EE-96B1-C91816F7ACBD}.Release|x64.Build.0 = Release|Any CPU
83-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
84-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Debug|Any CPU.Build.0 = Debug|Any CPU
85-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Debug|x64.ActiveCfg = Debug|Any CPU
86-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Debug|x64.Build.0 = Debug|Any CPU
87-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Release|Any CPU.ActiveCfg = Release|Any CPU
88-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Release|Any CPU.Build.0 = Release|Any CPU
89-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Release|x64.ActiveCfg = Release|Any CPU
90-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B}.Release|x64.Build.0 = Release|Any CPU
9171
{F6A4373B-0A3F-45F1-BA64-7AD30BB7F04C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
9272
{F6A4373B-0A3F-45F1-BA64-7AD30BB7F04C}.Debug|Any CPU.Build.0 = Debug|Any CPU
9373
{F6A4373B-0A3F-45F1-BA64-7AD30BB7F04C}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -128,15 +108,21 @@ Global
128108
{C2B70883-79CC-4216-886F-5F5EF0662924}.Release|Any CPU.Build.0 = Release|Any CPU
129109
{C2B70883-79CC-4216-886F-5F5EF0662924}.Release|x64.ActiveCfg = Release|Any CPU
130110
{C2B70883-79CC-4216-886F-5F5EF0662924}.Release|x64.Build.0 = Release|Any CPU
111+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
112+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
113+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Debug|x64.ActiveCfg = Debug|Any CPU
114+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Debug|x64.Build.0 = Debug|Any CPU
115+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
116+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Release|Any CPU.Build.0 = Release|Any CPU
117+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Release|x64.ActiveCfg = Release|Any CPU
118+
{D09566A4-693D-495A-B02D-C2CC1FCFEC2B}.Release|x64.Build.0 = Release|Any CPU
131119
EndGlobalSection
132120
GlobalSection(SolutionProperties) = preSolution
133121
HideSolutionNode = FALSE
134122
EndGlobalSection
135123
GlobalSection(NestedProjects) = preSolution
136124
{FD2D8DBB-FD8B-4DA0-A251-3C88AF1CE9F7} = {CA892A10-463B-4439-B5AA-D15C168D9117}
137125
{E7888A66-50C2-427D-9B47-5A924EB3A1DB} = {CA892A10-463B-4439-B5AA-D15C168D9117}
138-
{65E54210-5F02-45EE-96B1-C91816F7ACBD} = {AE4FC02A-2DF0-4D1E-916E-8C1F3955C4A1}
139-
{D932E58B-DCEF-49A9-BDEB-40F180B2F19B} = {AE4FC02A-2DF0-4D1E-916E-8C1F3955C4A1}
140126
{0DB41C96-7D02-41EE-8E7B-F2B1024A8659} = {D8EC0278-B4F9-4EF5-A4BE-FE2284C6ECED}
141127
{96F40ED5-9D9E-4D06-A308-BA76E0F3616C} = {D8EC0278-B4F9-4EF5-A4BE-FE2284C6ECED}
142128
{75D7E79F-6D04-431B-A268-7BB61925B75B} = {D8EC0278-B4F9-4EF5-A4BE-FE2284C6ECED}

Diff for: src/Audio/Vortice.Audio.OpenAL/OpenALSystem.cs

-16
This file was deleted.

Diff for: src/Audio/Vortice.Audio.OpenAL/Vortice.Audio.OpenAL.csproj

-12
This file was deleted.

Diff for: src/Audio/Vortice.Audio.XAudio2/Vortice.Audio.XAudio2.csproj

-16
This file was deleted.

Diff for: src/Vortice.Audio/AudioBackend.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright © Amer Koleci and Contributors.
2+
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
3+
4+
namespace Vortice.Audio;
5+
6+
public enum AudioBackend : byte
7+
{
8+
Default = 0,
9+
XAudio2,
10+
OpenAL,
11+
}

Diff for: src/Vortice.Audio/AudioEngine.cs

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright © Amer Koleci and Contributors.
2+
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
3+
4+
using Microsoft.Toolkit.Diagnostics;
5+
6+
namespace Vortice.Audio;
7+
8+
public abstract class AudioEngine : IDisposable
9+
{
10+
private volatile int _isDisposed;
11+
12+
protected AudioEngine()
13+
{
14+
}
15+
16+
/// <summary>
17+
/// Releases unmanaged resources and performs other cleanup operations.
18+
/// </summary>
19+
~AudioEngine()
20+
{
21+
if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
22+
{
23+
OnDispose();
24+
}
25+
}
26+
27+
/// <summary>
28+
/// Get the device backend type.
29+
/// </summary>
30+
public abstract AudioBackend BackendType { get; }
31+
32+
/// <summary>
33+
/// Gets whether or not the current instance has already been disposed.
34+
/// </summary>
35+
public bool IsDisposed
36+
{
37+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
38+
get
39+
{
40+
return _isDisposed != 0;
41+
}
42+
}
43+
44+
/// <inheritdoc />
45+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
46+
public void Dispose()
47+
{
48+
OnDispose();
49+
GC.SuppressFinalize(this);
50+
}
51+
52+
protected abstract void OnDispose();
53+
54+
/// <summary>
55+
/// Throws an <see cref="ObjectDisposedException" /> if the current instance has been disposed.
56+
/// </summary>
57+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
58+
protected void ThrowIfDisposed()
59+
{
60+
if (IsDisposed)
61+
{
62+
Throw();
63+
}
64+
void Throw()
65+
{
66+
throw new ObjectDisposedException(ToString());
67+
}
68+
}
69+
}

Diff for: src/Vortice.Audio/OpenAL/OpenALEngine.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright © Amer Koleci and Contributors.
2+
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
3+
4+
using static Vortice.Audio.OpenAL.OpenALNative;
5+
6+
namespace Vortice.Audio.OpenAL;
7+
8+
internal unsafe class OpenALEngine : AudioEngine
9+
{
10+
private readonly IntPtr _device;
11+
12+
public OpenALEngine()
13+
{
14+
_device = alcOpenDevice(null);
15+
}
16+
17+
/// <inheritdoc />
18+
protected override void OnDispose()
19+
{
20+
}
21+
22+
// <inheritdoc />
23+
public override AudioBackend BackendType => AudioBackend.OpenAL;
24+
}

Diff for: src/Audio/Vortice.Audio.OpenAL/OpenALNative.cs renamed to src/Vortice.Audio/OpenAL/OpenALNative.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// Copyright © Amer Koleci and Contributors.
22
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
33

4-
using System.Runtime.InteropServices;
5-
64
namespace Vortice.Audio.OpenAL;
75

86
internal unsafe static class OpenALNative
97
{
108
private static readonly IntPtr s_nativeLibrary;
11-
private static readonly delegate* unmanaged<sbyte*, nint> alcOpenDevice_ptr;
9+
private static readonly delegate* unmanaged<sbyte*, IntPtr> alcOpenDevice_ptr;
1210

13-
public static nint alcOpenDevice(sbyte* name) => alcOpenDevice_ptr(name);
11+
public static IntPtr alcOpenDevice(sbyte* name) => alcOpenDevice_ptr(name);
1412

1513
static OpenALNative()
1614
{

Diff for: src/Vortice.Audio/Vortice.Audio.csproj

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0</TargetFrameworks>
5+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6+
<DefineConstants Condition="'$(ExcludeXAudio2)' == 'true'">$(DefineConstants);EXCLUDE_XAUDIO2_BACKEND</DefineConstants>
7+
<DefineConstants Condition="'$(ExcludeOpenAL)' == 'true'">$(DefineConstants);EXCLUDE_OPENAL_BACKEND</DefineConstants>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Using Include="System.Runtime.InteropServices" />
12+
<Using Include="System.Runtime.CompilerServices" />
13+
14+
<Compile Remove="XAudio2/**/*" Condition="'$(ExcludeXAudio2)' == 'true'" />
15+
<Compile Remove="OpenAL/**/*" Condition="'$(ExcludeOpenAL)' == 'true'" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.Toolkit.Diagnostics" Version="7.1.2" />
20+
<PackageReference Include="Vortice.XAudio2 " Version="$(VorticeWindowsVersion)" />
21+
</ItemGroup>
22+
23+
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard2'))">
24+
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
25+
<PackageReference Include="System.Memory" Version="4.5.4" />
26+
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
27+
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
28+
</ItemGroup>
29+
30+
</Project>

Diff for: src/Audio/Vortice.Audio.XAudio2/XAudio2System.cs renamed to src/Vortice.Audio/XAudio2/XAudio2Engine.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44
using Vortice.XAudio2;
55
using static Vortice.XAudio2.XAudio2;
66

7-
namespace Vortice.Audio;
7+
namespace Vortice.Audio.XAudio2;
88

9-
public unsafe class XAudio2System : AudioSystem
9+
internal unsafe class XAudio2Engine : AudioEngine
1010
{
1111
private readonly IXAudio2 _xaudio2;
1212

13-
public XAudio2System()
13+
public XAudio2Engine()
1414
{
1515
_xaudio2 = XAudio2Create(ProcessorSpecifier.DefaultProcessor, registerCallback: true);
1616
}
17+
18+
/// <inheritdoc />
19+
protected override void OnDispose()
20+
{
21+
_xaudio2.Dispose();
22+
}
23+
24+
// <inheritdoc />
25+
public override AudioBackend BackendType => AudioBackend.XAudio2;
1726
}

Diff for: src/Vortice.Graphics/Vortice.Graphics.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0</TargetFrameworks>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<DefineConstants Condition="'$(ExcludeD3D11)' == 'true'">$(DefineConstants);EXCLUDE_D3D11_BACKEND</DefineConstants>
77
<DefineConstants Condition="'$(ExcludeD3D12)' == 'true'">$(DefineConstants);EXCLUDE_D3D12_BACKEND</DefineConstants>

Diff for: src/Vortice/Vortice.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.Toolkit.Diagnostics" Version="7.1.2" />
9-
<PackageReference Include="Vortice.Mathematics" Version="1.3.27" />
109
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
10+
<PackageReference Include="Vortice.Mathematics" Version="$(VorticeMathematicsVersion)" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
1414
<ProjectReference Include="..\Vortice.Graphics\Vortice.Graphics.csproj" />
15+
<ProjectReference Include="..\Vortice.Audio\Vortice.Audio.csproj" />
1516
</ItemGroup>
1617

1718
</Project>

0 commit comments

Comments
 (0)