fix: prevent idle sleep during playback
This commit is contained in:
@@ -75,6 +75,8 @@ struct CastPlaybackCheck {
|
||||
try await until(model, "pending LOAD follows acknowledged local pause") { model.state.status == PLAYER_PAUSED }
|
||||
}
|
||||
}
|
||||
requirePlaybackPower(system: !active || scenario == "disconnect-active", display: scenario == "cancel-connect",
|
||||
"handoff keeps the relay awake even after the local decoder pauses")
|
||||
if scenario == "reject-load" {
|
||||
try signal("observed")
|
||||
try await until(model, "LOAD rejection restores original local playback", permitError: true) {
|
||||
@@ -107,6 +109,7 @@ struct CastPlaybackCheck {
|
||||
if scenario.hasPrefix("shutdown-") {
|
||||
require(model.castDevice == nil && !model.castConnecting && !model.canOpen && !model.canClose,
|
||||
"shutdown releases Cast ownership and permanently disables the local player")
|
||||
requirePlaybackPower(system: false, display: false, "interrupted Cast shutdown releases sleep prevention")
|
||||
require(!model.setPlayback(playing: true) && !model.seekRelative(5) && model.volume == 0,
|
||||
"late receiver traffic cannot resume a destroyed player or replace local volume")
|
||||
print("PASS: " + scenario)
|
||||
@@ -187,29 +190,36 @@ struct CastPlaybackCheck {
|
||||
model.setVolume(0)
|
||||
model.open(source)
|
||||
try await until(model, "local source plays") { model.state.status == PLAYER_PLAYING && model.canSeek }
|
||||
requirePlaybackPower(system: true, display: true, "local video prevents system and display sleep")
|
||||
require(model.setPlayback(playing: false), "local pause accepted")
|
||||
try await until(model, "local pause acknowledged") { model.state.status == PLAYER_PAUSED && model.playbackIntent == nil }
|
||||
requirePlaybackPower(system: false, display: false, "local pause permits sleep")
|
||||
require(model.seekRelative(9.25 - model.state.position), "local restoration position accepted")
|
||||
require(!model.canCast, "Cast cannot transfer an unacknowledged local seek")
|
||||
try await until(model, "local position acknowledged") { !model.state.seek_pending && abs(model.state.position - 9.25) < 0.15 }
|
||||
model.cast(to: CastDevice(id: "loopback", name: "Loopback TV", host: "127.0.0.1", port: port))
|
||||
requirePlaybackPower(system: true, display: false, "pending Cast handoff protects the relay")
|
||||
try await until(model, "receiver load acknowledges paused handoff") {
|
||||
model.castDevice != nil && !model.castConnecting && model.canSeek && model.state.status == PLAYER_PAUSED
|
||||
}
|
||||
requirePlaybackPower(system: false, display: false, "paused Cast permits sleep")
|
||||
require(abs(model.state.position - 9.25) < 0.15, "Cast starts at acknowledged local position")
|
||||
require(!model.canStepFrame && model.bufferedRange == nil, "local decoder-only controls are not exposed while casting")
|
||||
require(model.setPlayback(playing: true), "remote play accepted")
|
||||
try await until(model, "receiver play acknowledged") { model.state.status == PLAYER_PLAYING && model.playbackIntent == nil }
|
||||
requirePlaybackPower(system: true, display: false, "playing Cast protects the relay but permits display sleep")
|
||||
for _ in 0..<64 { require(model.seekRelative(0.125), "rapid remote skips accumulate beyond queue capacity") }
|
||||
require(model.seekRelative(7), "final remote skip retains accumulated target")
|
||||
try await until(model, "receiver seek acknowledged") { !model.state.seek_pending && abs(model.state.position - 24.25) < 0.15 }
|
||||
require(model.setPlayback(playing: false), "remote pause accepted")
|
||||
try await until(model, "receiver pause acknowledged") { model.state.status == PLAYER_PAUSED && model.playbackIntent == nil }
|
||||
requirePlaybackPower(system: false, display: false, "receiver pause permits sleep")
|
||||
model.stopCasting()
|
||||
try await until(model, "local decoder restores receiver position paused") {
|
||||
model.castDevice == nil && model.state.status == PLAYER_PAUSED && !model.state.seek_pending &&
|
||||
abs(model.state.position - 24.25) < 0.15 && !model.isBusy
|
||||
}
|
||||
requirePlaybackPower(system: false, display: false, "paused local restoration permits sleep")
|
||||
require(abs((PlaybackProgress(defaults: defaults).position(for: source) ?? 0) - 24.25) < 0.15,
|
||||
"remote history is not overwritten by the abandoned local position")
|
||||
require(model.volume == 0, "local volume survives receiver volume changes")
|
||||
@@ -220,8 +230,10 @@ struct CastPlaybackCheck {
|
||||
model.castDevice == nil && model.commandError != nil && model.state.status == PLAYER_PLAYING
|
||||
}
|
||||
require(model.canSeek && model.state.position >= 24, "connection failure preserves a usable local timeline")
|
||||
requirePlaybackPower(system: true, display: true, "failed Cast restores local display protection")
|
||||
model.closeFile()
|
||||
try await until(model, "closed media releases Cast and decoder") { model.state.status == PLAYER_EMPTY }
|
||||
requirePlaybackPower(system: false, display: false, "closing Cast media releases sleep prevention")
|
||||
print("PASS: real local decode → TLS Cast LOAD/play/seek/pause → local restoration/history; failed connection recovery")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user