proper clean up of tracks when disconnecting
this was causing some crashes when disconnecting
正在显示
4 个修改的文件
包含
14 行增加
和
6 行删除
| @@ -353,10 +353,10 @@ constructor( | @@ -353,10 +353,10 @@ constructor( | ||
| 353 | // do nothing, may happen on older versions if attempting to unregister twice. | 353 | // do nothing, may happen on older versions if attempting to unregister twice. |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | + state = State.DISCONNECTED | ||
| 357 | + engine.close() | ||
| 356 | cleanupRoom() | 358 | cleanupRoom() |
| 357 | 359 | ||
| 358 | - engine.close() | ||
| 359 | - state = State.DISCONNECTED | ||
| 360 | listener?.onDisconnect(this, null) | 360 | listener?.onDisconnect(this, null) |
| 361 | listener = null | 361 | listener = null |
| 362 | _localParticipant?.dispose() | 362 | _localParticipant?.dispose() |
| @@ -159,6 +159,8 @@ class RemoteParticipant( | @@ -159,6 +159,8 @@ class RemoteParticipant( | ||
| 159 | listener?.onTrackUnpublished(publication, this) | 159 | listener?.onTrackUnpublished(publication, this) |
| 160 | eventBus.postEvent(ParticipantEvent.TrackUnpublished(this, publication), scope) | 160 | eventBus.postEvent(ParticipantEvent.TrackUnpublished(this, publication), scope) |
| 161 | } | 161 | } |
| 162 | + track?.dispose() | ||
| 163 | + publication.track = null | ||
| 162 | } | 164 | } |
| 163 | 165 | ||
| 164 | internal fun onSubscriptionPermissionUpdate(subscriptionPermissionUpdate: LivekitRtc.SubscriptionPermissionUpdate) { | 166 | internal fun onSubscriptionPermissionUpdate(subscriptionPermissionUpdate: LivekitRtc.SubscriptionPermissionUpdate) { |
| @@ -6,10 +6,7 @@ import io.livekit.android.events.TrackEvent | @@ -6,10 +6,7 @@ import io.livekit.android.events.TrackEvent | ||
| 6 | import io.livekit.android.room.track.video.VideoSinkVisibility | 6 | import io.livekit.android.room.track.video.VideoSinkVisibility |
| 7 | import io.livekit.android.room.track.video.ViewVisibility | 7 | import io.livekit.android.room.track.video.ViewVisibility |
| 8 | import io.livekit.android.util.LKLog | 8 | import io.livekit.android.util.LKLog |
| 9 | -import kotlinx.coroutines.CoroutineDispatcher | ||
| 10 | -import kotlinx.coroutines.CoroutineScope | ||
| 11 | -import kotlinx.coroutines.SupervisorJob | ||
| 12 | -import kotlinx.coroutines.launch | 9 | +import kotlinx.coroutines.* |
| 13 | import org.webrtc.VideoSink | 10 | import org.webrtc.VideoSink |
| 14 | import javax.inject.Named | 11 | import javax.inject.Named |
| 15 | import kotlin.math.max | 12 | import kotlin.math.max |
| @@ -96,4 +93,9 @@ class RemoteVideoTrack( | @@ -96,4 +93,9 @@ class RemoteVideoTrack( | ||
| 96 | } | 93 | } |
| 97 | } | 94 | } |
| 98 | } | 95 | } |
| 96 | + | ||
| 97 | + fun dispose() { | ||
| 98 | + super.dispose() | ||
| 99 | + coroutineScope.cancel() | ||
| 100 | + } | ||
| 99 | } | 101 | } |
-
请 注册 或 登录 后发表评论