Reputation:
I marshalled correctly to:
IntPtr buffer
Buffer is pointer to array of 2 pointers to arrays with respective data. The problem is that I get not accurate data, like if there's something missing in the data retrieved (e.g. missimg samples from stream of audio data).
// length is parameter
IntPtr[] temp = new IntPtr[2];
Marshal.Copy(buffer, temp, 0, 2);
bufferedData = new byte[bufferSize];
byte[] a = new byte[length];
byte[] b = new byte[length];
Marshal.Copy(temp[0], a, 0, length);
Marshal.Copy(temp[1], b, 0, length);
edit: sorry I forgot to write those 2 lines :)
Upvotes: 1
Views: 337
Reputation:
I finally solved it. I wasn't reading full input buffer by mistake. Thanks for all your help!
Upvotes: 1
Reputation: 11492
I don't know anything about C# so this is a complete guess, but - you seem to be copying from ints to bytes, is "length" the count in ints, or the count in bytes? Could there be a mixup there? This can be a problem in regular old C++ sometimes.
Upvotes: 0
Reputation: 117290
If buffer is a pointer to an array, you would need to read the pointer once more.
Effectively:
buffer = Marshal.ReadIntPtr(buffer);
Upvotes: 0
Reputation: 117290
Yes, you would need to copy the byte buffers too :)
Update: That looks better!
Upvotes: 0