Skip to content

Commit b563530

Browse files
committed
fixup! Port XAudio to Silk.NET
1 parent 5a19df7 commit b563530

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

sources/engine/Stride.Audio/Layers/XAudio/AudioProvider.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public Listener ListenerCreate(Device device)
100100
{
101101
var listener = new Listener();
102102
listener.device = device;
103-
listener.listener = null;
103+
listener.listener = new();
104104
return listener;
105105
}
106106

@@ -116,7 +116,6 @@ public void ListenerDisable(Listener listener)
116116

117117
public bool ListenerEnable(Listener listener)
118118
{
119-
//unused in Xaudio2
120119
return true;
121120
}
122121

@@ -149,13 +148,11 @@ public unsafe Source SourceCreate(Listener listener, int sampleRate, int maxNumb
149148
{
150149
//if spatialized we also need those structures to calculate 3D audio
151150
source.emitter = new();
152-
//memset(source.emitter_, 0x0, sizeof(X3DAUDIO_EMITTER));
153151
source.emitter.ChannelCount = 1;
154152
source.emitter.CurveDistanceScaler = 1;
155153
source.emitter.DopplerScaler = 1;
156154

157155
source.dsp_settings = new();
158-
//memset(source.dsp_settings_, 0x0, sizeof(X3DAUDIO_DSP_SETTINGS));
159156
source.dsp_settings.SrcChannelCount = 1;
160157
source.dsp_settings.DstChannelCount = AUDIO_CHANNELS;
161158
var matrix = stackalloc float[AUDIO_CHANNELS];
@@ -430,7 +427,7 @@ public unsafe void SourceSetPan(Source source, float pan)
430427
{
431428
if (source.Mono)
432429
{
433-
var panning = stackalloc float[2];
430+
var panning = new float[2];
434431
if (pan < 0)
435432
{
436433
panning[0] = 1.0f;
@@ -441,12 +438,14 @@ public unsafe void SourceSetPan(Source source, float pan)
441438
panning[0] = 1.0f - pan;
442439
panning[1] = 1.0f;
443440
}
444-
source.sourceVoice->SetOutputMatrix<IXAudio2MasteringVoice>(source.masteringVoice, 1, AUDIO_CHANNELS, panning, 0);
441+
fixed(float* panningPtr = &panning[0]){
442+
source.sourceVoice->SetOutputMatrix((IXAudio2Voice*)source.masteringVoice, 1, AUDIO_CHANNELS, panningPtr, 0);
443+
}
445444

446445
}
447446
else
448447
{
449-
var panning = stackalloc float[4];
448+
var panning = new float[4];
450449
if (pan < 0)
451450
{
452451
panning[0] = 1.0f;
@@ -461,7 +460,9 @@ public unsafe void SourceSetPan(Source source, float pan)
461460
panning[2] = 0.0f;
462461
panning[3] = 1.0f;
463462
}
464-
source.sourceVoice->SetOutputMatrix<IXAudio2MasteringVoice>(source.masteringVoice, 2, AUDIO_CHANNELS, panning, 0);
463+
fixed(float* panningPtr = &panning[0]){
464+
source.sourceVoice->SetOutputMatrix((IXAudio2Voice*)source.masteringVoice, 2, AUDIO_CHANNELS, panningPtr, 0);
465+
}
465466
}
466467
}
467468

@@ -529,8 +530,7 @@ public unsafe void SourceStop(Source source)
529530
}
530531

531532
public void Update(Device device)
532-
{
533-
//TODO: Add IUpdateAudioProvider ?
533+
{
534534
}
535535
}
536536

0 commit comments

Comments
 (0)