From 47d554997fb5a7474f987e6ab75a4b6e24cfd0bd Mon Sep 17 00:00:00 2001 From: Elias Holzer Date: Fri, 22 Mar 2024 14:56:17 +0100 Subject: [PATCH] Fixes audio not working in 6.0 --- deployment/VL.IO.NDI.nuspec | 2 +- src/Sender.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/deployment/VL.IO.NDI.nuspec b/deployment/VL.IO.NDI.nuspec index bdfdba0..167b361 100644 --- a/deployment/VL.IO.NDI.nuspec +++ b/deployment/VL.IO.NDI.nuspec @@ -2,7 +2,7 @@ VL.IO.NDI - 0.5.3-preview + 0.5.4-preview VL.IO.NDI vvvv, Matthias Husinsky, sebl, NewTek vvvv, Matthias Husinsky, sebl, NewTek diff --git a/src/Sender.cs b/src/Sender.cs index bd57334..3bca577 100644 --- a/src/Sender.cs +++ b/src/Sender.cs @@ -252,8 +252,11 @@ public unsafe void Send(AudioFrame audioFrame) if (audioFrame.IsPlanar) { - var buffer = audioFrame.Data.Span; - fixed (float* bufferPointer = buffer) + // As long as this package needs to run in 5.2 and 6.0 we can't use the Span property as it causes a MissingMethodException + //var buffer = audioFrame.Data.Span; + //fixed (float* bufferPointer = buffer) + var buffer = audioFrame.Data; + using var bufferHandle = buffer.Pin(); fixed (byte* metadataPointer = Utils.StringToUtf8(audioFrame.Metadata)) { var nativeAudioFrame = new NDIlib.audio_frame_v2_t() @@ -261,7 +264,7 @@ public unsafe void Send(AudioFrame audioFrame) channel_stride_in_bytes = buffer.Width * sizeof(float), no_channels = audioFrame.ChannelCount, no_samples = audioFrame.SampleCount, - p_data = new IntPtr(bufferPointer), + p_data = new IntPtr(bufferHandle.Pointer), p_metadata = new IntPtr(metadataPointer), sample_rate = audioFrame.SampleRate };