尝试克隆SecondaryBuffer但出现MemoryAccessViolation异常
我正在尝试克隆 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”类型的未处理异常
附加信息:尝试读取或写入受保护的内存。这通常表明其他内存已损坏。
有人有解决方案吗?
I'm trying to clone SecondaryBuffer
so I can play the same sound multiple times at the same time.
this is the code I'm using:
In the main thread:
Device sounddevice = new Device();
sounddevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
BufferDescription description = new BufferDescription();
description.ControlEffects = false;
SecondaryBuffer buffer = new SecondaryBuffer(file, description, sounddevice);
In a function running on different thread:
SecondaryBuffer buffer2 = buffer.Clone(sounddevice);
buffer2.Play(0, BufferPlayFlags.Default);
this is the exception I got on the Clone
function:
An unhandled exception of type 'System.AccessViolationException' occurred in Microsoft.DirectX.DirectSound.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Anyone got a solution for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论