开发者

Trying to clone SecondaryBuffer but got an MemoryAccessViolation exception

开发者 https://www.devze.com 2023-02-20 12:55 出处:网络
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:

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();
so开发者_开发技巧unddevice.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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号