正在显示
1 个修改的文件
包含
5 行增加
和
5 行删除
| @@ -36,7 +36,6 @@ import io.livekit.android.webrtc.isConnected | @@ -36,7 +36,6 @@ import io.livekit.android.webrtc.isConnected | ||
| 36 | import io.livekit.android.webrtc.isDisconnected | 36 | import io.livekit.android.webrtc.isDisconnected |
| 37 | import io.livekit.android.webrtc.toProtoSessionDescription | 37 | import io.livekit.android.webrtc.toProtoSessionDescription |
| 38 | import kotlinx.coroutines.* | 38 | import kotlinx.coroutines.* |
| 39 | -import kotlinx.coroutines.sync.Mutex | ||
| 40 | import livekit.LivekitModels | 39 | import livekit.LivekitModels |
| 41 | import livekit.LivekitRtc | 40 | import livekit.LivekitRtc |
| 42 | import livekit.LivekitRtc.JoinResponse | 41 | import livekit.LivekitRtc.JoinResponse |
| @@ -102,7 +101,6 @@ internal constructor( | @@ -102,7 +101,6 @@ internal constructor( | ||
| 102 | 101 | ||
| 103 | internal var reconnectType: ReconnectType = ReconnectType.DEFAULT | 102 | internal var reconnectType: ReconnectType = ReconnectType.DEFAULT |
| 104 | private var reconnectingJob: Job? = null | 103 | private var reconnectingJob: Job? = null |
| 105 | - private val reconnectingLock = Mutex() | ||
| 106 | private var fullReconnectOnNext = false | 104 | private var fullReconnectOnNext = false |
| 107 | 105 | ||
| 108 | private val pendingTrackResolvers: MutableMap<String, Continuation<LivekitModels.TrackInfo>> = | 106 | private val pendingTrackResolvers: MutableMap<String, Continuation<LivekitModels.TrackInfo>> = |
| @@ -301,6 +299,7 @@ internal constructor( | @@ -301,6 +299,7 @@ internal constructor( | ||
| 301 | if (isClosed) { | 299 | if (isClosed) { |
| 302 | return | 300 | return |
| 303 | } | 301 | } |
| 302 | + LKLog.v { "Close - $reason" } | ||
| 304 | isClosed = true | 303 | isClosed = true |
| 305 | hasPublished = false | 304 | hasPublished = false |
| 306 | sessionUrl = null | 305 | sessionUrl = null |
| @@ -343,12 +342,14 @@ internal constructor( | @@ -343,12 +342,14 @@ internal constructor( | ||
| 343 | /** | 342 | /** |
| 344 | * reconnect Signal and PeerConnections | 343 | * reconnect Signal and PeerConnections |
| 345 | */ | 344 | */ |
| 345 | + @Synchronized | ||
| 346 | internal fun reconnect() { | 346 | internal fun reconnect() { |
| 347 | - val didLock = reconnectingLock.tryLock() | ||
| 348 | - if (!didLock) { | 347 | + if (reconnectingJob?.isActive == true) { |
| 348 | + LKLog.d { "Reconnection is already in progress" } | ||
| 349 | return | 349 | return |
| 350 | } | 350 | } |
| 351 | if (this.isClosed) { | 351 | if (this.isClosed) { |
| 352 | + LKLog.d { "Skip reconnection - engine is closed" } | ||
| 352 | return | 353 | return |
| 353 | } | 354 | } |
| 354 | val url = sessionUrl | 355 | val url = sessionUrl |
| @@ -463,7 +464,6 @@ internal constructor( | @@ -463,7 +464,6 @@ internal constructor( | ||
| 463 | if (reconnectingJob == job) { | 464 | if (reconnectingJob == job) { |
| 464 | reconnectingJob = null | 465 | reconnectingJob = null |
| 465 | } | 466 | } |
| 466 | - reconnectingLock.unlock() | ||
| 467 | } | 467 | } |
| 468 | } | 468 | } |
| 469 | 469 |
-
请 注册 或 登录 后发表评论