This commit is contained in:
2026-03-18 12:24:37 -07:00
parent b0e89ff950
commit 7c526784a8
6 changed files with 729 additions and 245 deletions

View File

@@ -1079,6 +1079,7 @@ class _PlaybackState:
fetch_attempt_at: float = 0.0
cache_wait_key: Optional[str] = None
cache_wait_started_at: float = 0.0
cache_wait_next_probe_at: float = 0.0
def clear(self, client: MPVIPCClient, *, clear_hash: bool = True) -> None:
"""Reset backend resolution and clean up any active OSD / external subtitle.
@@ -1096,6 +1097,7 @@ class _PlaybackState:
self.times = []
self.cache_wait_key = None
self.cache_wait_started_at = 0.0
self.cache_wait_next_probe_at = 0.0
if self.loaded_key is not None:
_osd_clear_and_restore(client)
self.loaded_key = None
@@ -1244,6 +1246,7 @@ def run_auto_overlay(
state.key = None
state.cache_wait_key = None
state.cache_wait_started_at = 0.0
state.cache_wait_next_probe_at = 0.0
if store_override and (not hash_override or hash_override == state.file_hash):
reg = _make_registry()
@@ -1390,15 +1393,21 @@ def run_auto_overlay(
if state.cache_wait_key != state.key:
state.cache_wait_key = state.key
state.cache_wait_started_at = now
state.cache_wait_next_probe_at = 0.0
elif state.cache_wait_next_probe_at > now:
time.sleep(max(0.05, min(0.5, state.cache_wait_next_probe_at - now)))
continue
pending = is_notes_prefetch_pending(state.store_name, state.file_hash)
waited_s = max(0.0, now - float(state.cache_wait_started_at or now))
if pending and waited_s < pending_wait_s:
time.sleep(min(max(poll_s, 0.05), 0.2))
state.cache_wait_next_probe_at = now + max(0.2, min(0.5, pending_wait_s - waited_s))
time.sleep(max(0.05, min(0.5, state.cache_wait_next_probe_at - now)))
continue
if waited_s < cache_wait_s:
time.sleep(min(max(poll_s, 0.05), 0.2))
state.cache_wait_next_probe_at = now + max(0.2, min(0.5, cache_wait_s - waited_s))
time.sleep(max(0.05, min(0.5, state.cache_wait_next_probe_at - now)))
continue
try:
@@ -1413,6 +1422,7 @@ def run_auto_overlay(
state.cache_wait_key = None
state.cache_wait_started_at = 0.0
state.cache_wait_next_probe_at = 0.0
try:
_log(