davidliu

proper clean up of tracks when disconnecting

this was causing some crashes when disconnecting
... ... @@ -353,10 +353,10 @@ constructor(
// do nothing, may happen on older versions if attempting to unregister twice.
}
state = State.DISCONNECTED
engine.close()
cleanupRoom()
engine.close()
state = State.DISCONNECTED
listener?.onDisconnect(this, null)
listener = null
_localParticipant?.dispose()
... ...
... ... @@ -159,6 +159,8 @@ class RemoteParticipant(
listener?.onTrackUnpublished(publication, this)
eventBus.postEvent(ParticipantEvent.TrackUnpublished(this, publication), scope)
}
track?.dispose()
publication.track = null
}
internal fun onSubscriptionPermissionUpdate(subscriptionPermissionUpdate: LivekitRtc.SubscriptionPermissionUpdate) {
... ...
... ... @@ -6,10 +6,7 @@ import io.livekit.android.events.TrackEvent
import io.livekit.android.room.track.video.VideoSinkVisibility
import io.livekit.android.room.track.video.ViewVisibility
import io.livekit.android.util.LKLog
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import org.webrtc.VideoSink
import javax.inject.Named
import kotlin.math.max
... ... @@ -96,4 +93,9 @@ class RemoteVideoTrack(
}
}
}
fun dispose() {
super.dispose()
coroutineScope.cancel()
}
}
\ No newline at end of file
... ...
... ... @@ -119,6 +119,10 @@ open class Track(
open fun stop() {
rtcTrack.setEnabled(false)
}
open fun dispose() {
rtcTrack.dispose()
}
}
... ...