fix(qt): preserve saved resume state after silent owner restoration
A shutdown that restores only the owner queue must not persist the stopped player position over the saved owner resume point. Track that teardown outcome and retain the existing session snapshot. cx
This commit is contained in:
3 files changed
+16
-6
No files matched your search
@@ -4270,7 +4270,7 @@ fn main() {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(())) => true,
|
||||
Ok(Ok(can_persist_owner)) => can_persist_owner,
|
||||
Ok(Err(error)) => {
|
||||
log::warn!("[qbz-qt] QConnect shutdown failed: {error}");
|
||||
false
|
||||
@@ -4299,8 +4299,8 @@ fn main() {
|
||||
qconnect_owner_safe = qconnect_stopped;
|
||||
if !qconnect_stopped {
|
||||
log::warn!(
|
||||
"[qbz-qt] QConnect shutdown did not finish within 3s; \
|
||||
skipping session persistence to avoid saving delegated state"
|
||||
"[qbz-qt] preserving the saved owner session after QConnect shutdown \
|
||||
(teardown incomplete or owner playback intentionally not restored)"
|
||||
);
|
||||
}
|
||||
if !notification_withdrawn {
|
||||
|
||||
@@ -52,6 +52,7 @@ pub type QtDelegationCoordinator = DelegationCoordinator<QtDelegationHost>;
|
||||
|
||||
const SHUTDOWN_RESTORE_OWNER: u8 = 0;
|
||||
const SHUTDOWN_RESTORE_QUEUE_ONLY: u8 = 1;
|
||||
const SHUTDOWN_OWNER_QUEUE_RESTORED: u8 = 2;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct OwnerSnapshot {
|
||||
@@ -272,6 +273,12 @@ impl QtDelegationHost {
|
||||
self.projection.current_session_id(&self.authority, stamp)
|
||||
}
|
||||
|
||||
/// A silent exit restored the queue but not the player's resume position.
|
||||
/// Preserve the already-persisted owner session instead of saving idle zero.
|
||||
pub fn shutdown_restored_queue_only(&self) -> bool {
|
||||
self.shutdown_mode.load(Ordering::Acquire) == SHUTDOWN_OWNER_QUEUE_RESTORED
|
||||
}
|
||||
|
||||
pub fn set_shutdown_restore_owner(&self, restore: bool) {
|
||||
self.shutdown_mode.store(
|
||||
if restore {
|
||||
@@ -877,7 +884,9 @@ impl DelegationHost for QtDelegationHost {
|
||||
// Process exit still restores the owner's queue for persistence,
|
||||
// but must never schedule audible playback or reopen the DAC.
|
||||
let _ = self.runtime.core().stop();
|
||||
let _ = self.restore_owner_snapshot().await;
|
||||
if self.restore_owner_snapshot().await.is_some() {
|
||||
self.shutdown_mode.store(SHUTDOWN_OWNER_QUEUE_RESTORED, Ordering::Release);
|
||||
}
|
||||
None
|
||||
} else {
|
||||
// A pending candidate may have captured a snapshot, but disabling an
|
||||
|
||||
@@ -2598,8 +2598,9 @@ impl QtQconnectService {
|
||||
}
|
||||
|
||||
/// Process exit restores ownership bookkeeping, never audible playback.
|
||||
pub async fn disconnect_for_shutdown(&self) -> Result<(), String> {
|
||||
self.disconnect_with_owner_policy(false).await.map(|_| ())
|
||||
pub async fn disconnect_for_shutdown(&self) -> Result<bool, String> {
|
||||
self.disconnect_with_owner_policy(false).await?;
|
||||
Ok(!self.delegation_host.shutdown_restored_queue_only())
|
||||
}
|
||||
|
||||
pub async fn disconnect_safely(&self) -> Result<QconnectDisconnectOutcome, String> {
|
||||
|
||||
Reference in new issue
Block a user