我正在尝试克隆SecondaryBuffer
,以便我可以同时多次播放相同的声音。
这是我正在使用的代码: 在主线程中:
Device sounddevice = new Device();
sounddevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
BufferDescription description = new BufferDescription();
description.ControlEffects = false;
SecondaryBuffer buffer = new SecondaryBuffer(file, description, sounddevice);
在不同线程上运行的函数中:
SecondaryBuffer buffer2 = buffer.Clone(sounddevice);
buffer2.Play(0, BufferPlayFlags.Default);
这是我在Clone
函数上的例外:
Microsoft.DirectX.DirectSound.dll中出现未处理的“System.AccessViolationException”类型异常
附加信息:尝试读取或写入受保护的内存。这通常表明其他内存已损坏。
任何人都有解决方案吗?