Skip to content

Commit 624935f

Browse files
committed
Merge branch 'ladvoc/fix-audio-leak' into ladvoc/add-apm
2 parents 6294861 + 7c6f099 commit 624935f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
> This SDK is currently in Developer Preview mode and not ready for production use. There will be bugs and APIs may change during this period.
1616
>
17-
> We welcome and appreciate any feedback or contributions. You can create issues here or chat live with us in the #rust-developer-preview channel within the [LiveKit Community Slack](https://livekit.io/join-slack).
17+
> We welcome and appreciate any feedback or contributions. You can create issues here or chat live with us in the #sdk-native channel within the [LiveKit Community Slack](https://livekit.io/join-slack).
1818
1919
<!--BEGIN_DESCRIPTION-->
2020
Use this SDK to add realtime video, audio and data features to your Unity app. By connecting to <a href="https://livekit.io/">LiveKit</a> Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code.

Runtime/Scripts/AudioFrame.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class AudioFrame : IDisposable
2525

2626
public AudioFrameBufferInfo Info => _info;
2727

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

@@ -46,8 +47,8 @@ internal AudioFrame(uint sampleRate, uint numChannels, uint samplesPerChannel) {
4647
_samplesPerChannel = samplesPerChannel;
4748
unsafe
4849
{
49-
var data = new NativeArray<byte>(Length, Allocator.Persistent);
50-
_dataPtr = (IntPtr)NativeArrayUnsafeUtility.GetUnsafePtr(data);
50+
_allocatedData = new NativeArray<byte>(Length, Allocator.Persistent);
51+
_dataPtr = (IntPtr)NativeArrayUnsafeUtility.GetUnsafePtr(_allocatedData);
5152
}
5253
}
5354
~AudioFrame()
@@ -65,6 +66,10 @@ protected virtual void Dispose(bool disposing)
6566
{
6667
if (!_disposed)
6768
{
69+
if (_allocatedData.IsCreated)
70+
{
71+
_allocatedData.Dispose();
72+
}
6873
_disposed = true;
6974
}
7075
}

0 commit comments

Comments
 (0)