Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is your sample size bigger than 1 byte? If so then ...</p> <p>on ARM it is important to keep data aligned, so if you allocate BYTE (one byte) buffer and later cast it to SHORT (two bytes), then if BYTE buffer was allocated on odd address then you will get unaligned data access.</p> <p>So if your sample size is two bytes then you must ensure that your BYTE buffer address is always even. </p> <p>To verify this you can check what value does lpData have when error appears, if it is odd then simply allocate 1 byte more and send buffer+1 to winapi function.</p> <hr> <p>below is sample code with proper alignment, found at: <a href="http://www.utdallas.edu/~nsg051000/AmbientNoise4/Wave.cs" rel="nofollow">http://www.utdallas.edu/~nsg051000/AmbientNoise4/Wave.cs</a></p> <pre><code> /// /// Read a data buffer from the supplied BinaryReader. This method will /// allocate memory for the data buffer it is not already allocated. /// /// BinaryReader containing data /// Size, in bytes, to be read /// MMSYSERR.NOERROR if successful public MMSYSERR Read(BinaryReader rdr, uint readLength, int align) { uint bufferLength = readLength; if (bufferLength % align != 0) bufferLength += (uint)(align - (bufferLength % align)); dwBufferLength = bufferLength; byte[] data = new byte[readLength]; rdr.Read(data, 0, data.Length); if (lpData == IntPtr.Zero) lpData = Memory.LocalAlloc(Memory.LMEM_FIXED, (uint)bufferLength); if (lpData == IntPtr.Zero) return MMSYSERR.NOMEM; Marshal.Copy(data, 0, lpData, data.Length); return MMSYSERR.NOERROR; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload