Skip to content

Commit 2a18ab9

Browse files
committed
better audio provider detection
1 parent 21ecfc1 commit 2a18ab9

20 files changed

+92
-100
lines changed

sources/engine/Stride.Audio/DynamicSoundSource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ protected virtual bool CanFill
128128
if (freeBuffer == null)
129129
return false;
130130

131+
#if LINUX || OSX
131132
freeBuffers.Enqueue(freeBuffer.Value);
133+
#endif
132134
return true;
133135
}
134136
}

sources/engine/Stride.Audio/Layers/AudioLayer.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Stride.Audio;
1010
/// </summary>
1111
public class AudioLayer
1212
{
13-
private static IAudioProvider al;
13+
private static AudioProvider al;
1414

1515
static AudioLayer()
1616
{
@@ -19,12 +19,7 @@ static AudioLayer()
1919

2020
public static void Init()
2121
{
22-
if(OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || OperatingSystem.IsIOS())
23-
al = new OpenALProvider();
24-
if(OperatingSystem.IsAndroid())
25-
al = new OpenSLESProvider();
26-
// if(OperatingSystem.IsWindows())
27-
// al = new XAudio2Provider();
22+
al = new AudioProvider();
2823
}
2924

3025
public static Device? Create(string deviceName, DeviceFlags flags)
File renamed without changes.
File renamed without changes.

sources/engine/Stride.Audio/Layers/HrtfEnvironment.cs renamed to sources/engine/Stride.Audio/Layers/Common/HrtfEnvironment.cs

File renamed without changes.

sources/engine/Stride.Audio/Layers/IInitializable.cs renamed to sources/engine/Stride.Audio/Layers/Common/IInitializable.cs

File renamed without changes.

sources/engine/Stride.Audio/Layers/IAudioProvider.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

sources/engine/Stride.Audio/Layers/Buffer.cs renamed to sources/engine/Stride.Audio/Layers/OpenAL/AudioBuffer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33
namespace Stride.Audio;
44

5-
public struct AudioBuffer : IInitializable
5+
public partial struct AudioBuffer : IInitializable
66
{
7+
#if LINUX || OSX
78
public short[] Pcm { get; internal set; }
89
public int Size { get; internal set; }
910
public int SampleRate { get; internal set; }
1011
public BufferType Type { get; internal set; }
1112
public bool Initialized { get; internal set; }
1213
public uint Value;
14+
#endif
1315
}

sources/engine/Stride.Audio/Layers/OpenAL/OpenALProvider.cs renamed to sources/engine/Stride.Audio/Layers/OpenAL/AudioProvider.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
#if LINUX || OSX
34
using System;
45
using System.Runtime.InteropServices;
56
using Silk.NET.OpenAL;
67
using Stride.Core.Mathematics;
78

89
namespace Stride.Audio;
910

10-
internal sealed unsafe class OpenALProvider : IAudioProvider
11+
internal sealed unsafe class AudioProvider
1112
{
1213
private readonly ALContext alc;
1314
private readonly AL al;
14-
public OpenALProvider()
15+
public AudioProvider()
1516
{
1617
alc = ALContext.GetApi();
1718
al = AL.GetApi();
@@ -424,4 +425,5 @@ public void Update(Device device)
424425
}
425426
device.DeviceLock.Unlock();
426427
}
427-
}
428+
}
429+
#endif

sources/engine/Stride.Audio/Layers/ContextState.cs renamed to sources/engine/Stride.Audio/Layers/OpenAL/ContextState.cs

File renamed without changes.

0 commit comments

Comments
 (0)