From 8b60f1735633e374feb5ee631802aa32e9349ce6 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 15 Aug 2022 23:51:10 +0800 Subject: [PATCH] chore: Correctly release the cloned stream. --- lib/src/voip/call.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/voip/call.dart b/lib/src/voip/call.dart index 9de4a161..ef0a99d7 100644 --- a/lib/src/voip/call.dart +++ b/lib/src/voip/call.dart @@ -82,11 +82,9 @@ class WrappedMediaStream { Future dispose() async { renderer.srcObject = null; - if (isLocal() && !isGroupCall && stream != null) { - if (isWeb) { - for (final element in stream!.getTracks()) { - await element.stop(); - } + if (isLocal() && stream != null) { + for (final element in stream!.getTracks()) { + await element.stop(); } await stream?.dispose(); stream = null; @@ -737,7 +735,9 @@ class CallSession { if (purpose == SDPStreamMetadataPurpose.Usermedia) { speakerOn = type == CallType.kVideo; - if (!voip.delegate.isWeb && !voip.delegate.isBackgroud) { + if (!voip.delegate.isWeb && + !voip.delegate.isBackgroud && + stream.getAudioTracks().isNotEmpty) { final audioTrack = stream.getAudioTracks()[0]; audioTrack.enableSpeakerphone(speakerOn); }