diff --git a/src/Aurio.FFmpeg/Aurio.FFmpeg.csproj b/src/Aurio.FFmpeg/Aurio.FFmpeg.csproj
index 02da2c5..ebc41c3 100644
--- a/src/Aurio.FFmpeg/Aurio.FFmpeg.csproj
+++ b/src/Aurio.FFmpeg/Aurio.FFmpeg.csproj
@@ -12,6 +12,7 @@
..\..\nativesrc\out\build\linux-$(FFmpegProxyBuildConfig)\aurioffmpegproxy
true
Extension library for Aurio, which provides audio decoding through FFmpeg (see https://ffmpeg.org/).
+ True
diff --git a/src/Aurio.FFmpeg/FFmpegReader.cs b/src/Aurio.FFmpeg/FFmpegReader.cs
index 4e81d9b..1757c9f 100644
--- a/src/Aurio.FFmpeg/FFmpegReader.cs
+++ b/src/Aurio.FFmpeg/FFmpegReader.cs
@@ -75,31 +75,18 @@ public FFmpegReader(FileInfo fileInfo, Type mode)
/// the stream to decode
/// the types of data to read
/// optional filename as a hint for FFmpeg to determine the data format
- public FFmpegReader(Stream stream, Type mode, string fileName)
+ public unsafe FFmpegReader(Stream stream, Type mode, string fileName)
{
ValidateNativeLibraryAvailability();
this.filename = fileName ?? "bufferedIO_stream";
this.mode = mode;
- var transferBuffer = new byte[0];
readPacketDelegate = delegate(IntPtr opaque, IntPtr buffer, int bufferSize)
{
- /* NOTE there's no way to cast the IntPtr to a byte array which is required
- * for stream reading, so we need to add an intermediary transfer buffer.
- */
- // Increase transfer buffer's size if too small
- if (transferBuffer.Length < bufferSize)
- {
- transferBuffer = new byte[bufferSize];
- }
- // Read data into transfer buffer
- int bytesRead = stream.Read(transferBuffer, 0, bufferSize);
-
- // Transfer data to unmanaged memory
- Marshal.Copy(transferBuffer, 0, buffer, bytesRead);
+ var bufferSpan = new Span(buffer.ToPointer(), bufferSize);
+ int bytesRead = stream.Read(bufferSpan);
- // Return number of bytes read
return bytesRead;
};
seekDelegate = delegate(IntPtr opaque, long offset, int whence)