XAudio2: Fix missing dispose.
This commit is contained in:
parent
39b54f7202
commit
0405eb7c73
|
@ -117,13 +117,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (sampleCount == 0) return;
|
||||
_bufferPool.Release(_sourceVoice.State.BuffersQueued);
|
||||
int byteCount = sampleCount * Sound.BlockAlign;
|
||||
var buffer = _bufferPool.Obtain(byteCount);
|
||||
Buffer.BlockCopy(samples, sampleOffset * Sound.BlockAlign, buffer.Bytes, 0, byteCount);
|
||||
_sourceVoice.SubmitSourceBuffer(new AudioBuffer
|
||||
{
|
||||
AudioBytes = byteCount,
|
||||
AudioData = buffer.DataStream
|
||||
});
|
||||
var item = _bufferPool.Obtain(byteCount);
|
||||
Buffer.BlockCopy(samples, sampleOffset * Sound.BlockAlign, item.Bytes, 0, byteCount);
|
||||
item.AudioBuffer.AudioBytes = byteCount;
|
||||
_sourceVoice.SubmitSourceBuffer(item.AudioBuffer);
|
||||
_runningSamplesQueued += sampleCount;
|
||||
}
|
||||
|
||||
|
@ -136,7 +133,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
foreach (BufferPoolItem item in _availableItems.Concat(_obtainedItems))
|
||||
{
|
||||
item.DataStream.Dispose();
|
||||
item.AudioBuffer.AudioData.Dispose();
|
||||
item.AudioBuffer.Dispose();
|
||||
}
|
||||
_availableItems.Clear();
|
||||
_obtainedItems.Clear();
|
||||
|
@ -171,15 +169,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public class BufferPoolItem
|
||||
{
|
||||
public int MaxLength { get; private set; }
|
||||
public byte[] Bytes { get; private set; }
|
||||
public DataStream DataStream { get; private set; }
|
||||
public int MaxLength { get; }
|
||||
public byte[] Bytes { get; }
|
||||
public AudioBuffer AudioBuffer { get; }
|
||||
|
||||
public BufferPoolItem(int length)
|
||||
{
|
||||
MaxLength = length;
|
||||
Bytes = new byte[MaxLength];
|
||||
DataStream = new DataStream(Bytes, true, false);
|
||||
AudioBuffer = new AudioBuffer
|
||||
{
|
||||
AudioData = new DataStream(Bytes, true, false)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue