fix(player): recover a failed stream on Linux instead of stopping (DR-130)

A recoverable player error meant "playback is over": the frontend's error
handler stopped the player unconditionally, so a wifi blip killed the
track. Android already decides in its JNI callback, but MpvBackend is
constructed before PlayerController exists, so its event thread has no
controller to ask.

So MPV reports the failure and the frontend echoes it into the new
player_recover_stream command — the same shape as PlaybackEnded ->
player_on_playback_ended, keeping the decision in Rust. The command
re-opens the stream where it stopped, with the existing attempt budget
and backoff, and returns whether it handled it; only a false answer
falls through to the old stop path.

Android now reports the errors it has already declined as
*unrecoverable*, so the echo never asks the same question twice.

TRACES: UR-004, UR-040 | DR-130 | UT-117
This commit is contained in:
2026-08-04 20:15:28 +02:00
parent 32f8de5c91
commit 30dc3ba7f6
10 changed files with 186 additions and 11 deletions
+6 -4
View File
@@ -1390,11 +1390,13 @@ impl PlayerController {
/// The wait grows with the attempt number so a short outage has time to
/// clear, and the shared budget stops the retries when it doesn't.
///
/// Only *called* from the Android error callback (`#[cfg(android)]`), but
/// compiled and unit-tested on the host, hence `allow(dead_code)` off-Android.
/// Called from the Android error callback, which decides in-process, and from
/// `player_recover_stream`, which is how the same decision reaches the
/// backends whose event thread has no controller to call — MPV is built
/// before the controller exists, so on Linux the error is emitted, echoed by
/// the frontend, and decided here.
///
/// TRACES: UR-040, UR-004 | DR-129 | UT-117
#[cfg_attr(not(target_os = "android"), allow(dead_code))]
/// TRACES: UR-040, UR-004 | DR-129, DR-130 | UT-117
pub fn recoverable_error_resume(&self) -> Option<(f64, u64)> {
self.claim_stream_resume()
.map(|(position, attempt)| (position, attempt as u64 * RESUME_BACKOFF_STEP_SECS))