mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-09 17:49:47 +00:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
commit
1aa45c2156
2 changed files with 20 additions and 5 deletions
|
@ -66,6 +66,7 @@ import java.time.OffsetDateTime
|
||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
import java.util.Base64
|
import java.util.Base64
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlin.math.min
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
class StateSync {
|
class StateSync {
|
||||||
|
@ -372,6 +373,9 @@ class StateSync {
|
||||||
|
|
||||||
if (Settings.instance.synchronization.discoverThroughRelay) {
|
if (Settings.instance.synchronization.discoverThroughRelay) {
|
||||||
_threadRelay = Thread {
|
_threadRelay = Thread {
|
||||||
|
var backoffs: Array<Long> = arrayOf(1000, 5000, 10000, 20000)
|
||||||
|
var backoffIndex = 0;
|
||||||
|
|
||||||
while (_started) {
|
while (_started) {
|
||||||
try {
|
try {
|
||||||
Log.i(TAG, "Starting relay session...")
|
Log.i(TAG, "Starting relay session...")
|
||||||
|
@ -417,6 +421,8 @@ class StateSync {
|
||||||
},
|
},
|
||||||
onClose = { socketClosed = true },
|
onClose = { socketClosed = true },
|
||||||
onHandshakeComplete = { relaySession ->
|
onHandshakeComplete = { relaySession ->
|
||||||
|
backoffIndex = 0
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
try {
|
try {
|
||||||
while (_started && !socketClosed) {
|
while (_started && !socketClosed) {
|
||||||
|
@ -484,7 +490,7 @@ class StateSync {
|
||||||
} finally {
|
} finally {
|
||||||
_relaySession?.stop()
|
_relaySession?.stop()
|
||||||
_relaySession = null
|
_relaySession = null
|
||||||
Thread.sleep(5000)
|
Thread.sleep(backoffs[min(backoffs.size - 1, backoffIndex++)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.apply { start() }
|
}.apply { start() }
|
||||||
|
|
|
@ -18,6 +18,7 @@ import com.futo.platformplayer.casting.StateCasting
|
||||||
import com.futo.platformplayer.constructs.Event1
|
import com.futo.platformplayer.constructs.Event1
|
||||||
import com.futo.platformplayer.constructs.Event2
|
import com.futo.platformplayer.constructs.Event2
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import com.futo.platformplayer.UIDialogs
|
||||||
|
|
||||||
class DeviceViewHolder : ViewHolder {
|
class DeviceViewHolder : ViewHolder {
|
||||||
private val _layoutDevice: FrameLayout;
|
private val _layoutDevice: FrameLayout;
|
||||||
|
@ -55,9 +56,17 @@ class DeviceViewHolder : ViewHolder {
|
||||||
|
|
||||||
val connect = {
|
val connect = {
|
||||||
device?.let { dev ->
|
device?.let { dev ->
|
||||||
StateCasting.instance.activeDevice?.stopCasting();
|
if (dev.isReady) {
|
||||||
StateCasting.instance.connectDevice(dev);
|
StateCasting.instance.activeDevice?.stopCasting()
|
||||||
onConnect.emit(dev);
|
StateCasting.instance.connectDevice(dev)
|
||||||
|
onConnect.emit(dev)
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
view.context?.let { UIDialogs.toast(it, "Device not ready, may be offline") }
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
//Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +93,7 @@ class DeviceViewHolder : ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
_textName.text = d.name;
|
_textName.text = d.name;
|
||||||
_imageOnline.visibility = if (isOnlineDevice) View.VISIBLE else View.GONE
|
_imageOnline.visibility = if (isOnlineDevice && d.isReady) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
if (!d.isReady) {
|
if (!d.isReady) {
|
||||||
_imageLoader.visibility = View.GONE;
|
_imageLoader.visibility = View.GONE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue