这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Runtime/Scripts/AudioFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class AudioFrame : IDisposable

public AudioFrameBufferInfo Info => _info;

private NativeArray<byte> _allocatedData; // Only used if the frame's data is allocated by Unity
private IntPtr _dataPtr;
public IntPtr Data => _dataPtr;

Expand All @@ -44,8 +45,8 @@ internal AudioFrame(uint sampleRate, uint numChannels, uint samplesPerChannel) {
_samplesPerChannel = samplesPerChannel;
unsafe
{
var data = new NativeArray<byte>(Length, Allocator.Persistent);
_dataPtr = (IntPtr)NativeArrayUnsafeUtility.GetUnsafePtr(data);
_allocatedData = new NativeArray<byte>(Length, Allocator.Persistent);
_dataPtr = (IntPtr)NativeArrayUnsafeUtility.GetUnsafePtr(_allocatedData);
}
}
~AudioFrame()
Expand All @@ -63,6 +64,10 @@ protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (_allocatedData.IsCreated)
{
_allocatedData.Dispose();
}
_disposed = true;
}
}
Expand Down