Updates
This commit is contained in:
parent
e2d5ef03eb
commit
5e39665a54
@ -1,6 +1,7 @@
|
|||||||
package no.iktdev.streamit.content.convert
|
package no.iktdev.streamit.content.convert
|
||||||
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import no.iktdev.library.subtitle.Syncro
|
import no.iktdev.library.subtitle.Syncro
|
||||||
@ -20,15 +21,21 @@ class ConvertRunner(val referenceId: String, val listener: IConvertListener) {
|
|||||||
private fun getReade(inputFile: File): BaseReader? {
|
private fun getReade(inputFile: File): BaseReader? {
|
||||||
return Reader(inputFile).getSubtitleReader()
|
return Reader(inputFile).getSubtitleReader()
|
||||||
}
|
}
|
||||||
|
private val maxDelay = 1000 * 5
|
||||||
|
private var currentDelayed = 0
|
||||||
suspend fun readAndConvert (subtitleInfo: SubtitleInfo) {
|
suspend fun readAndConvert (subtitleInfo: SubtitleInfo) {
|
||||||
val inFile = File(subtitleInfo.inputFile)
|
val inFile = File(subtitleInfo.inputFile)
|
||||||
if (!inFile.canRead()) {
|
while (!inFile.canRead()) {
|
||||||
logger.error { "$referenceId ${subtitleInfo.inputFile}: Cant read file!" }
|
if (currentDelayed > maxDelay) {
|
||||||
withContext(Dispatchers.Default) {
|
logger.error { "Could not out wait lock on file!" }
|
||||||
listener.onError(referenceId, subtitleInfo, "Cant read file!")
|
withContext(Dispatchers.Default) {
|
||||||
|
listener.onError(referenceId, subtitleInfo, "Cant read file!")
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return
|
logger.error { "$referenceId ${subtitleInfo.inputFile}: Cant read file!" }
|
||||||
|
delay(500)
|
||||||
|
currentDelayed += 500
|
||||||
}
|
}
|
||||||
val reader = getReade(inFile)
|
val reader = getReade(inFile)
|
||||||
val dialogs = reader?.read()
|
val dialogs = reader?.read()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user