Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 120 additions & 80 deletions src/Accelerate/vImageTypes.cs

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/AudioToolbox/AudioConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,16 @@ AudioStreamPacketDependencyDescription [] packetDependencies
unsafe {
fixed (AudioStreamPacketDependencyDescription* packetDependenciesPtr = packetDependencies) {
fixed (AudioStreamPacketDescription* packetDescriptionPtr = packetDescriptions) {
return AudioConverterFillComplexBufferWithPacketDependencies (
GetCheckedHandle (),
&FillComplexBufferShared,
(IntPtr) this_handle,
(uint*) Unsafe.AsPointer<int> (ref outputDataPacketSize),
(IntPtr) outputData,
packetDescriptionPtr,
packetDependenciesPtr);
fixed (int* outputDataPacketSizePtr = &outputDataPacketSize) {
return AudioConverterFillComplexBufferWithPacketDependencies (
GetCheckedHandle (),
&FillComplexBufferShared,
(IntPtr) this_handle,
(uint*) outputDataPacketSizePtr,
(IntPtr) outputData,
packetDescriptionPtr,
packetDependenciesPtr);
}
}
}
}
Expand Down
67 changes: 41 additions & 26 deletions src/AudioToolbox/AudioFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,13 +1270,15 @@ unsafe extern static OSStatus AudioFileReadPacketData (
{
OSStatus r;
fixed (AudioStreamPacketDescription* pdesc = descriptions) {
r = AudioFileReadPacketData (Handle,
useCache ? (byte) 1 : (byte) 0,
(int*) Unsafe.AsPointer<int> (ref count),
pdesc,
inStartingPacket,
(int*) Unsafe.AsPointer<int> (ref nPackets),
buffer);
fixed (int* countPtr = &count, nPacketsPtr = &nPackets) {
r = AudioFileReadPacketData (Handle,
useCache ? (byte) 1 : (byte) 0,
countPtr,
pdesc,
inStartingPacket,
nPacketsPtr,
buffer);
}
}

error = (AudioFileError) r;
Expand Down Expand Up @@ -1556,7 +1558,9 @@ public AudioFileError WritePackets (bool useCache, int numBytes, AudioStreamPack

unsafe {
fixed (AudioStreamPacketDescription* packetDescriptionsPtr = packetDescriptions) {
return AudioFileWritePackets (Handle, useCache ? (byte) 1 : (byte) 0, numBytes, packetDescriptionsPtr, startingPacket, (int*) Unsafe.AsPointer<int> (ref numPackets), buffer);
fixed (int* numPacketsPtr = &numPackets) {
return AudioFileWritePackets (Handle, useCache ? (byte) 1 : (byte) 0, numBytes, packetDescriptionsPtr, startingPacket, numPacketsPtr, buffer);
}
}
}
}
Expand Down Expand Up @@ -1600,15 +1604,17 @@ public AudioFileError WritePackets (bool useCache, AudioStreamPacketDescription
unsafe {
fixed (AudioStreamPacketDescription* packetDescriptionsPtr = packetDescriptions) {
fixed (AudioStreamPacketDependencyDescription* packetDependenciesPtr = packetDependencies) {
return AudioFileWritePacketsWithDependencies (
GetCheckedHandle (),
useCache.AsByte (),
(uint) numBytes,
packetDescriptionsPtr,
packetDependenciesPtr,
startingPacket,
(uint*) Unsafe.AsPointer<int> (ref numPackets),
buffer);
fixed (int* numPacketsPtr = &numPackets) {
return AudioFileWritePacketsWithDependencies (
GetCheckedHandle (),
useCache.AsByte (),
(uint) numBytes,
packetDescriptionsPtr,
packetDependenciesPtr,
startingPacket,
(uint*) numPacketsPtr,
buffer);
}
}
}
}
Expand Down Expand Up @@ -1715,7 +1721,8 @@ public AudioFileError GetUserDataSize (uint userDataId, int index, out ulong siz
{
size = 0;
unsafe {
return (AudioFileError) AudioFileGetUserDataSize64 (Handle, userDataId, index, (ulong*) Unsafe.AsPointer<ulong> (ref size));
fixed (ulong* sizePtr = &size)
return (AudioFileError) AudioFileGetUserDataSize64 (Handle, userDataId, index, sizePtr);
}
}

Expand Down Expand Up @@ -1749,7 +1756,8 @@ public int GetUserData (int userDataID, int index, ref int size, IntPtr userData
#endif
{
unsafe {
return AudioFileGetUserData (Handle, userDataID, index, (int*) Unsafe.AsPointer<int> (ref size), userData);
fixed (int* sizePtr = &size)
return AudioFileGetUserData (Handle, userDataID, index, sizePtr, userData);
}
}

Expand Down Expand Up @@ -1785,7 +1793,8 @@ public AudioFileError GetUserData (AudioFileChunkType chunkType, int index, ref
public AudioFileError GetUserData (uint userDataId, int index, long offset, ref int size, IntPtr userData)
{
unsafe {
return (AudioFileError) AudioFileGetUserDataAtOffset (Handle, userDataId, index, offset, (int*) Unsafe.AsPointer<int> (ref size), userData);
fixed (int* sizePtr = &size)
return (AudioFileError) AudioFileGetUserDataAtOffset (Handle, userDataId, index, offset, sizePtr, userData);
}
}

Expand Down Expand Up @@ -1931,7 +1940,9 @@ public bool GetPropertyInfo (AudioFileProperty property, out int size, out int w
size = default;
writable = default;
unsafe {
error = AudioFileGetPropertyInfo (Handle, property, (int*) Unsafe.AsPointer<int> (ref size), (int*) Unsafe.AsPointer<int> (ref writable));
fixed (int* sizePtr = &size, writablePtr = &writable) {
error = AudioFileGetPropertyInfo (Handle, property, sizePtr, writablePtr);
}
}
return error == AudioFileError.Success;
}
Expand Down Expand Up @@ -1959,7 +1970,8 @@ public bool GetPropertyInfo (AudioFileProperty property, out int size, out bool
size = default;

unsafe {
error = AudioFileGetPropertyInfo (Handle, property, (int*) Unsafe.AsPointer<int> (ref size), &writableValue);
fixed (int* sizePtr = &size)
error = AudioFileGetPropertyInfo (Handle, property, sizePtr, &writableValue);
}
writable = writableValue != 0;

Expand Down Expand Up @@ -1988,7 +2000,8 @@ public bool IsPropertyWritable (AudioFileProperty property)
public bool GetProperty (AudioFileProperty property, ref int dataSize, IntPtr outdata)
{
unsafe {
return AudioFileGetProperty (Handle, property, (int*) Unsafe.AsPointer<int> (ref dataSize), outdata) == 0;
fixed (int* dataSizePtr = &dataSize)
return AudioFileGetProperty (Handle, property, dataSizePtr, outdata) == 0;
}
}

Expand All @@ -2007,9 +2020,11 @@ public IntPtr GetProperty (AudioFileProperty property, out int size)
return IntPtr.Zero;

unsafe {
var rv = AudioFileGetProperty (Handle, property, (int*) Unsafe.AsPointer<int> (ref size), buffer);
if (rv == 0)
return buffer;
fixed (int* sizePtr = &size) {
var rv = AudioFileGetProperty (Handle, property, sizePtr, buffer);
if (rv == 0)
return buffer;
}
}
Marshal.FreeHGlobal (buffer);
return IntPtr.Zero;
Expand Down
31 changes: 20 additions & 11 deletions src/AudioToolbox/AudioFileGlobalInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,28 @@ public static HFSTypeCode[] AllHFSTypeCodes {
static bool TryGetGlobalInfoSize (AudioFileGlobalProperty propertyId, out uint size)
{
size = 0;
var rv = AudioFileGetGlobalInfoSize (propertyId, 0, null, (uint*) Unsafe.AsPointer<uint> (ref size));
return rv == 0;
fixed (uint* sizePtr = &size) {
var rv = AudioFileGetGlobalInfoSize (propertyId, 0, null, sizePtr);
return rv == 0;
}
}

static bool TryGetGlobalInfoSize (AudioFileGlobalProperty propertyId, AudioFileType fileType, out uint size)
{
size = 0;
var rv = AudioFileGetGlobalInfoSize (propertyId, sizeof (AudioFileType), (void*) &fileType, (uint*) Unsafe.AsPointer<uint> (ref size));
return rv == 0;
fixed (uint* sizePtr = &size) {
var rv = AudioFileGetGlobalInfoSize (propertyId, sizeof (AudioFileType), (void*) &fileType, sizePtr);
return rv == 0;
}
}

static bool TryGetGlobalInfoSize (AudioFileGlobalProperty propertyId, AudioFileTypeAndFormatID audioFileTypeAndFormatId, out uint size)
{
size = 0;
var rv = AudioFileGetGlobalInfoSize (propertyId, (uint) sizeof (AudioFileTypeAndFormatID), (void*) &audioFileTypeAndFormatId, (uint*) Unsafe.AsPointer<uint> (ref size));
return rv == 0;
fixed (uint* sizePtr = &size) {
var rv = AudioFileGetGlobalInfoSize (propertyId, (uint) sizeof (AudioFileTypeAndFormatID), (void*) &audioFileTypeAndFormatId, sizePtr);
return rv == 0;
}
}

[DllImport (Constants.AudioToolboxLibrary)]
Expand Down Expand Up @@ -304,17 +310,20 @@ static bool TryGetGlobalInfo (AudioFileGlobalProperty propertyId, AudioFileType
{
var size = (uint) sizeof (IntPtr);
outPropertyData = default;
var rv = AudioFileGetGlobalInfo (propertyId, sizeof (AudioFileType), &fileType, &size, (IntPtr*) Unsafe.AsPointer<IntPtr> (ref outPropertyData));
return rv == 0;

fixed (IntPtr* outPropertyDataPtr = &outPropertyData) {
var rv = AudioFileGetGlobalInfo (propertyId, sizeof (AudioFileType), &fileType, &size, outPropertyDataPtr);
return rv == 0;
}
}

static bool TryGetGlobalInfo (AudioFileGlobalProperty propertyId, out IntPtr outPropertyData)
{
var size = (uint) sizeof (IntPtr);
outPropertyData = default;
var rv = AudioFileGetGlobalInfo (propertyId, 0, null, &size, (IntPtr*) Unsafe.AsPointer<IntPtr> (ref outPropertyData));
return rv == 0;
fixed (IntPtr* outPropertyDataPtr = &outPropertyData) {
var rv = AudioFileGetGlobalInfo (propertyId, 0, null, &size, outPropertyDataPtr);
return rv == 0;
}
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/AudioToolbox/AudioFileStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ public AudioFileStreamStatus Seek (long packetOffset, out long dataByteOffset, o
int v = 0;
dataByteOffset = 0;
unsafe {
LastError = AudioFileStreamSeek (handle, packetOffset, (long*) Unsafe.AsPointer<long> (ref dataByteOffset), &v);
fixed (long* dataByteOffsetPtr = &dataByteOffset)
LastError = AudioFileStreamSeek (handle, packetOffset, dataByteOffsetPtr, &v);
}
if (LastError != AudioFileStreamStatus.Ok) {
isEstimate = false;
Expand Down Expand Up @@ -502,7 +503,8 @@ static AudioFileStreamStatus AudioFileStreamGetPropertyInfo (
AudioFileStreamStatus rv;
outPropertyDataSize = 0;
unsafe {
rv = AudioFileStreamGetPropertyInfo (inAudioFileStream, inPropertyID, (int*) Unsafe.AsPointer<int> (ref outPropertyDataSize), &writable);
fixed (int* outPropertyDataSizePtr = &outPropertyDataSize)
rv = AudioFileStreamGetPropertyInfo (inAudioFileStream, inPropertyID, outPropertyDataSizePtr, &writable);
}
isWritable = writable != 0;
return rv;
Expand Down Expand Up @@ -530,7 +532,8 @@ public bool GetProperty (AudioFileStreamProperty property, ref int dataSize, Int
if (outPropertyData == IntPtr.Zero)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (outPropertyData));
unsafe {
return AudioFileStreamGetProperty (handle, property, (int*) Unsafe.AsPointer<int> (ref dataSize), outPropertyData) == 0;
fixed (int* dataSizePtr = &dataSize)
return AudioFileStreamGetProperty (handle, property, dataSizePtr, outPropertyData) == 0;
}
}

Expand Down Expand Up @@ -565,7 +568,8 @@ public IntPtr GetProperty (AudioFileStreamProperty property, out int size)
return IntPtr.Zero;

unsafe {
LastError = AudioFileStreamGetProperty (handle, property, (int*) Unsafe.AsPointer<int> (ref size), buffer);
fixed (int* sizePtr = &size)
LastError = AudioFileStreamGetProperty (handle, property, sizePtr, buffer);
}
if (LastError == 0)
return buffer;
Expand Down
Loading
Loading