Beispiel #1
0
        public OscWriter(int capacity = 4096)
        {
            Buffer = new byte[capacity];

            // Even though Unity's GC does not move objects around, pin them to be safe.
            m_BufferPtr     = PtrUtil.Pin <byte, byte>(Buffer, out m_BufferHandle);
            m_BufferMidiPtr = (MidiMessage *)m_BufferPtr;

            m_FloatSwapPtr   = PtrUtil.Pin <float, byte>(m_FloatSwap, out m_FloatSwapHandle);
            m_DoubleSwapPtr  = PtrUtil.Pin <double, byte>(m_DoubleSwap, out m_DoubleSwapHandle);
            m_Color32SwapPtr = PtrUtil.Pin <Color32, byte>(m_Color32Swap, out m_Color32SwapHandle);
        }
Beispiel #2
0
        internal OscMessageValues(byte[] buffer, int elementCapacity = 8)
        {
            ElementCount   = 0;
            Tags           = new TypeTag[elementCapacity];
            Offsets        = new int[elementCapacity];
            m_SharedBuffer = buffer;

            fixed(byte *bufferPtr = buffer)
            {
                SharedBufferPtr = bufferPtr;
            }

            // pin byte swap buffers in place, so that we can count on the pointers never changing
            m_Swap32Handle = GCHandle.Alloc(m_SwapBuffer32, GCHandleType.Pinned);
            var swap32Ptr = m_Swap32Handle.AddrOfPinnedObject();

            SwapBuffer32Ptr      = (float *)swap32Ptr;
            SwapBuffer32UintPtr  = (uint *)swap32Ptr;
            SwapBufferColor32Ptr = (Color32 *)(byte *)swap32Ptr;

            SwapBuffer64Ptr = PtrUtil.Pin <byte, double>(m_SwapBuffer64, out m_Swap64Handle);
        }