mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-03 16:17:03 +00:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
commit
0d16dd0006
2 changed files with 17 additions and 24 deletions
|
@ -27,6 +27,7 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class PackageBridge : V8Package {
|
||||
@Transient
|
||||
|
@ -110,7 +111,7 @@ class PackageBridge : V8Package {
|
|||
}
|
||||
|
||||
var timeoutCounter = 0;
|
||||
var timeoutMap = HashSet<Int>();
|
||||
var timeoutMap = ConcurrentHashMap<Int, Any?>();
|
||||
@V8Function
|
||||
fun setTimeout(func: V8ValueFunction, timeout: Long): Int {
|
||||
val id = timeoutCounter++;
|
||||
|
@ -120,8 +121,7 @@ class PackageBridge : V8Package {
|
|||
delay(timeout);
|
||||
if (_plugin.isStopped)
|
||||
return@launch;
|
||||
synchronized(timeoutMap) {
|
||||
if(!timeoutMap.contains(id)) {
|
||||
if (!timeoutMap.containsKey(id)) {
|
||||
_plugin.busy {
|
||||
if (!_plugin.isStopped)
|
||||
JavetResourceUtils.safeClose(funcClone);
|
||||
|
@ -129,17 +129,14 @@ class PackageBridge : V8Package {
|
|||
return@launch;
|
||||
}
|
||||
timeoutMap.remove(id);
|
||||
}
|
||||
try {
|
||||
_plugin.busy {
|
||||
if (!_plugin.isStopped)
|
||||
funcClone.callVoid(null, arrayOf<Any>());
|
||||
}
|
||||
}
|
||||
catch(ex: Throwable) {
|
||||
} catch (ex: Throwable) {
|
||||
Logger.e(TAG, "Failed timeout callback", ex);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
_plugin.busy {
|
||||
if (!_plugin.isStopped)
|
||||
JavetResourceUtils.safeClose(funcClone);
|
||||
|
@ -148,18 +145,14 @@ class PackageBridge : V8Package {
|
|||
//}
|
||||
}
|
||||
};
|
||||
synchronized(timeoutMap) {
|
||||
timeoutMap.add(id);
|
||||
}
|
||||
timeoutMap.put(id, true);
|
||||
return id;
|
||||
}
|
||||
@V8Function
|
||||
fun clearTimeout(id: Int) {
|
||||
synchronized(timeoutMap) {
|
||||
if(timeoutMap.contains(id))
|
||||
if (timeoutMap.containsKey(id))
|
||||
timeoutMap.remove(id);
|
||||
}
|
||||
}
|
||||
@V8Function
|
||||
fun sleep(length: Int) {
|
||||
Thread.sleep(length.toLong());
|
||||
|
|
|
@ -580,7 +580,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
|
|||
DefaultHttpDataSource.Factory().setUserAgent(DEFAULT_USER_AGENT);
|
||||
|
||||
if(dataSource is JSHttpDataSource.Factory && videoSource is JSDashManifestMergingRawSource)
|
||||
dataSource.setRequestExecutor2(videoSource.audio.getRequestExecutor());
|
||||
dataSource.setRequestExecutor2(withContext(Dispatchers.IO){videoSource.audio.getRequestExecutor()});
|
||||
_lastVideoMediaSource = DashMediaSource.Factory(dataSource)
|
||||
.createMediaSource(
|
||||
DashManifestParser().parse(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue