Preserve device timestamp offsets across output reopen and counter wrap
This commit is contained in:
1 parent
3226865ad7
commit
a165372bbe
2 files changed
+12
-3
No files matched your search
@@ -32,5 +32,13 @@ internal class CallOutputPosition {
|
||||
}
|
||||
|
||||
fun played(raw: Int, written: Long): Long? = head.update(raw, written - base)?.let { base + it }
|
||||
fun timestamp(local: Long): Long = if (local < 0) -1 else base + local
|
||||
fun timestamp(local: Long, written: Long): Long {
|
||||
if (local < 0) return -1
|
||||
var extended = local
|
||||
if (local <= 0xffffffffL) {
|
||||
extended = ((written - base) and -0x100000000L) or local
|
||||
if (extended > written - base) extended -= 0x100000000L
|
||||
}
|
||||
return if (extended < 0) -1 else base + extended
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user