diff --git a/com.unity.renderstreaming/Runtime/Scripts/AudioStreamSender.cs b/com.unity.renderstreaming/Runtime/Scripts/AudioStreamSender.cs index 59882ab84..ddd78fa40 100644 --- a/com.unity.renderstreaming/Runtime/Scripts/AudioStreamSender.cs +++ b/com.unity.renderstreaming/Runtime/Scripts/AudioStreamSender.cs @@ -311,8 +311,11 @@ void _OnStartedStream(string connectionId) void _OnStoppedStream(string connectionId) { - m_sourceImpl?.Dispose(); - m_sourceImpl = null; + if (Transceivers.Count <= 0) + { + m_sourceImpl?.Dispose(); + m_sourceImpl = null; + } } internal override WaitForCreateTrack CreateTrack() diff --git a/com.unity.renderstreaming/Runtime/Scripts/VideoStreamSender.cs b/com.unity.renderstreaming/Runtime/Scripts/VideoStreamSender.cs index 9237cdd76..08006b6df 100644 --- a/com.unity.renderstreaming/Runtime/Scripts/VideoStreamSender.cs +++ b/com.unity.renderstreaming/Runtime/Scripts/VideoStreamSender.cs @@ -496,8 +496,11 @@ private protected override void OnDestroy() void _OnStoppedStream(string connectionId) { - m_sourceImpl?.Dispose(); - m_sourceImpl = null; + if (Transceivers.Count <= 0) + { + m_sourceImpl?.Dispose(); + m_sourceImpl = null; + } } internal override WaitForCreateTrack CreateTrack()