Skip to content

Commit

Permalink
Don't unlock the mutex when its not locked (#1165)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-apostolov authored Aug 26, 2024
1 parent c61ad58 commit a77a13f
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,10 @@ public class RtcSession internal constructor(
return@synchronized
}

val enabledRids = event.changePublishQuality.video_senders.firstOrNull()?.layers?.associate {
it.name to it.active
}
val enabledRids =
event.changePublishQuality.video_senders.firstOrNull()?.layers?.associate {
it.name to it.active
}
dynascaleLogger.i { "enabled rids: $enabledRids}" }
val params = sender.parameters
val updatedEncodings: MutableList<Encoding> = mutableListOf()
Expand Down Expand Up @@ -1069,9 +1070,10 @@ public class RtcSession internal constructor(
fun handleEvent(event: VideoEvent) {
logger.i { "[rtc handleEvent] #sfu; event: $event" }
if (event is JoinCallResponseEvent) {
logger.i { "[rtc handleEvent] unlocking joinEventReceivedMutex" }

joinEventReceivedMutex.unlock()
if (joinEventReceivedMutex.isLocked) {
logger.i { "[rtc handleEvent] unlocking joinEventReceivedMutex" }
joinEventReceivedMutex.unlock()
}
}
if (event is SfuDataEvent) {
coroutineScope.launch {
Expand Down Expand Up @@ -1410,7 +1412,13 @@ public class RtcSession internal constructor(
track_id = track.id(),
track_type = trackType,
layers = layers,
mid = transceiver.mid ?: extractMid(sdp, track, screenShareTrack, trackType, transceivers),
mid = transceiver.mid ?: extractMid(
sdp,
track,
screenShareTrack,
trackType,
transceivers,
),
)
}
return tracks
Expand All @@ -1429,6 +1437,7 @@ public class RtcSession internal constructor(
TrackType.TRACK_TYPE_VIDEO
}
}

else -> TrackType.TRACK_TYPE_UNSPECIFIED
}

Expand Down Expand Up @@ -1475,7 +1484,10 @@ public class RtcSession internal constructor(
return media.mid.toString()
}

private fun createVideoLayers(transceiver: RtpTransceiver, captureResolution: CaptureFormat): List<VideoLayer> {
private fun createVideoLayers(
transceiver: RtpTransceiver,
captureResolution: CaptureFormat,
): List<VideoLayer> {
// we tell the Sfu which resolutions we're sending
return transceiver.sender.parameters.encodings.map {
val scaleBy = it.scaleResolutionDownBy ?: 1.0
Expand Down Expand Up @@ -1715,7 +1727,13 @@ public class RtcSession internal constructor(
}
}

suspend fun switchSfu(sfuName: String, sfuUrl: String, sfuToken: String, remoteIceServers: List<IceServer>, failedToSwitch: () -> Unit) {
suspend fun switchSfu(
sfuName: String,
sfuUrl: String,
sfuToken: String,
remoteIceServers: List<IceServer>,
failedToSwitch: () -> Unit,
) {
logger.i { "[switchSfu] from ${this.sfuUrl} to $sfuUrl" }
val timer = clientImpl.debugInfo.trackTime("call.switchSfu")

Expand Down

0 comments on commit a77a13f

Please sign in to comment.