chore: Correctly release the cloned stream.

This commit is contained in:
cloudwebrtc 2022-08-15 23:51:10 +08:00
parent 651abc7c14
commit 8b60f17356
1 changed files with 6 additions and 6 deletions

View File

@ -82,11 +82,9 @@ class WrappedMediaStream {
Future<void> 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);
}