If the WaveFormat of the wave provider used as the parameter for Init is of type WaveFormatExtraData
The call within InitializeDirectSound to GCHandle.Alloc fails with an ArgumentException complaining that the “Object contains non-primitive or non-blittable data.”.
This is due to the extraData array of bytes field. Although it is a fixed size, alloc is still unable to pin the array because the array type itself is non-primitive and so cannot be pinned.
public TestPlay(Stream in)
{
var waveStream = new WaveFileReader(in);
var player = new DirectSoundOut(DirectSoundOut.DSDEVID_DefaultPlayback);
player.Init(waveStream);
player.Play();
//Waiting for play to stop removed for brevity.
}
The call within InitializeDirectSound to GCHandle.Alloc fails with an ArgumentException complaining that the “Object contains non-primitive or non-blittable data.”.
This is due to the extraData array of bytes field. Although it is a fixed size, alloc is still unable to pin the array because the array type itself is non-primitive and so cannot be pinned.
public TestPlay(Stream in)
{
var waveStream = new WaveFileReader(in);
var player = new DirectSoundOut(DirectSoundOut.DSDEVID_DefaultPlayback);
player.Init(waveStream);
player.Play();
//Waiting for play to stop removed for brevity.
}