public static CMBlockBuffer CreateEmpty (uint subBlockCapacity, CMBlockBufferFlags flags, out CMBlockBufferError error)
		{
			IntPtr buffer;
			error = CMBlockBufferCreateEmpty (IntPtr.Zero, subBlockCapacity, flags, out buffer);
			if (error != CMBlockBufferError.None)
				return null;

			return new CMBlockBuffer (buffer, true);
		}
Example #2
0
        public static CMBlockBuffer FromBuffer(CMBlockBuffer targetBuffer, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            // From docs targetBuffer must not be null unless the PermitEmptyReference flag is set
            if (!flags.HasFlag(CMBlockBufferFlags.PermitEmptyReference))
            {
                if (targetBuffer == null)
                {
                    throw new ArgumentNullException("targetBuffer");
                }
            }

            IntPtr buffer;

            error = CMBlockBufferCreateWithBufferReference(IntPtr.Zero, targetBuffer == null ? IntPtr.Zero : targetBuffer.handle, offsetToData, dataLength, flags, out buffer);
            if (error != CMBlockBufferError.None)
            {
                return(null);
            }

            return(new CMBlockBuffer(buffer, true));
        }
Example #3
0
        public static CMBlockBuffer CreateEmpty(uint subBlockCapacity, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            IntPtr buffer;

            error = CMBlockBufferCreateEmpty(IntPtr.Zero, subBlockCapacity, flags, out buffer);
            if (error != CMBlockBufferError.None)
            {
                return(null);
            }

            return(new CMBlockBuffer(buffer, true));
        }
Example #4
0
        public static CMBlockBuffer CreateContiguous(CMBlockBuffer sourceBuffer, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            if (sourceBuffer == null)
            {
                throw new ArgumentNullException("sourceBuffer");
            }

            IntPtr buffer;

            if (customBlockSource == null)
            {
                error = CMBlockBufferCreateContiguous(IntPtr.Zero, sourceBuffer.handle, IntPtr.Zero, IntPtr.Zero, offsetToData, dataLength, flags, out buffer);
            }
            else
            {
                error = CMBlockBufferCreateContiguous(IntPtr.Zero, sourceBuffer.handle, IntPtr.Zero, ref customBlockSource.Cblock, offsetToData, dataLength, flags, out buffer);
            }

            if (error != CMBlockBufferError.None)
            {
                return(null);
            }

            var block = new CMBlockBuffer(buffer, true);

            block.customAllocator = customBlockSource;
            return(block);
        }
Example #5
0
        public static CMBlockBuffer FromMemoryBlock(byte [] data, nuint offsetToData, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var allocator = new CMManagedArrayBlockAllocator(data);

            return(FromMemoryBlock(IntPtr.Zero, (uint)data.Length, allocator, offsetToData, (uint)data.Length, flags, out error));
        }
Example #6
0
        public static CMBlockBuffer FromMemoryBlock(IntPtr memoryBlock, nuint blockLength, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            var blockAllocator = memoryBlock == IntPtr.Zero ? IntPtr.Zero : CFAllocator.Null.Handle;

            IntPtr buffer;

            if (customBlockSource == null)
            {
                error = CMBlockBufferCreateWithMemoryBlock(IntPtr.Zero, memoryBlock, blockLength, blockAllocator, IntPtr.Zero, offsetToData, dataLength, flags, out buffer);
            }
            else
            {
                error = CMBlockBufferCreateWithMemoryBlock(IntPtr.Zero, memoryBlock, blockLength, blockAllocator, ref customBlockSource.Cblock, offsetToData, dataLength, flags, out buffer);
            }

            if (error != CMBlockBufferError.None)
            {
                return(null);
            }

            var block = new CMBlockBuffer(buffer, true);

            block.customAllocator = customBlockSource;
            return(block);
        }
Example #7
0
        public static CMBlockBuffer FromMemoryBlock(byte [] data, nuint offsetToData, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            if (data == null)
                throw new ArgumentNullException (nameof (data));

            var allocator = new CMManagedArrayBlockAllocator (data);
            return FromMemoryBlock (IntPtr.Zero, (uint) data.Length, allocator, offsetToData, (uint) data.Length, flags, out error);
        }
Example #8
0
        public static CMBlockBuffer FromMemoryBlock(IntPtr memoryBlock, nuint blockLength, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            var blockAllocator = memoryBlock == IntPtr.Zero ? IntPtr.Zero : CFAllocator.Null.Handle;
            IntPtr buffer;
            if (customBlockSource == null)
                error = CMBlockBufferCreateWithMemoryBlock (IntPtr.Zero, memoryBlock, blockLength, blockAllocator, IntPtr.Zero, offsetToData, dataLength, flags, out buffer);
            else
                error = CMBlockBufferCreateWithMemoryBlock (IntPtr.Zero, memoryBlock, blockLength, blockAllocator, ref customBlockSource.Cblock, offsetToData, dataLength, flags, out buffer);

            if (error != CMBlockBufferError.None)
                return null;

            var block = new CMBlockBuffer (buffer, true);
            block.customAllocator = customBlockSource;
            return block;
        }
Example #9
0
        public static CMBlockBuffer FromBuffer(CMBlockBuffer targetBuffer, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            // From docs targetBuffer must not be null unless the PermitEmptyReference flag is set
            if (!flags.HasFlag (CMBlockBufferFlags.PermitEmptyReference))
                if (targetBuffer == null)
                    throw new ArgumentNullException ("targetBuffer");

            IntPtr buffer;
            error = CMBlockBufferCreateWithBufferReference (IntPtr.Zero, targetBuffer == null ? IntPtr.Zero : targetBuffer.handle, offsetToData, dataLength, flags, out buffer);
            if (error != CMBlockBufferError.None)
                return null;

            return new CMBlockBuffer (buffer, true);
        }
Example #10
0
        public static CMBlockBuffer CreateContiguous(CMBlockBuffer sourceBuffer, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            if (sourceBuffer == null)
                throw new ArgumentNullException ("sourceBuffer");

            IntPtr buffer;
            if (customBlockSource == null)
                error = CMBlockBufferCreateContiguous (IntPtr.Zero, sourceBuffer.handle, IntPtr.Zero, IntPtr.Zero, offsetToData, dataLength, flags, out buffer);
            else
                error = CMBlockBufferCreateContiguous (IntPtr.Zero, sourceBuffer.handle, IntPtr.Zero, ref customBlockSource.Cblock, offsetToData, dataLength, flags, out buffer);

            if (error != CMBlockBufferError.None)
                return null;

            var block = new CMBlockBuffer (buffer, true);
            block.customAllocator = customBlockSource;
            return block;
        }
Example #11
0
        public static CMBlockBuffer?FromBuffer(CMBlockBuffer?targetBuffer, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
        {
            // From docs targetBuffer must not be null unless the PermitEmptyReference flag is set
            if (!flags.HasFlag(CMBlockBufferFlags.PermitEmptyReference))
            {
                if (targetBuffer is null)
                {
                    ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(targetBuffer));
                }
            }

            IntPtr buffer;

            error = CMBlockBufferCreateWithBufferReference(IntPtr.Zero, targetBuffer.GetHandle(), offsetToData, dataLength, flags, out buffer);
            if (error != CMBlockBufferError.None)
            {
                return(null);
            }

            return(new CMBlockBuffer(buffer, true));
        }