Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/xcl/src/hle/acphal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ pub struct Channel {
impl Channel {
pub fn connect(&mut self, now: Instant) {
self.connected = true;
// A reconnect starts a fresh channel: messages queued for the old one
// (a MSG_DISCONNECT nobody popped, stale command acks) must not surface.
self.messages.clear();
self.next_frame = Some(now + FRAME);
}

Expand Down Expand Up @@ -1137,6 +1140,18 @@ mod tests {
assert_eq!(c.pop(later).map(|m| m.kind), Some(MSG_DISCONNECTED));
}

#[test]
fn reconnect_drops_messages_queued_for_the_old_channel() {
let t0 = Instant::now();
let mut c = Channel::default();
c.connect(t0);
c.disconnect(); // queues MSG_DISCONNECTED; the title never pops it
c.connect(t0);
assert_eq!(c.pop(t0), None, "the stale disconnect must not surface on the new channel");
let later = t0 + FRAME * 3;
assert_eq!(c.pop(later).map(|m| m.kind), Some(MSG_AUDIO_FRAME));
}

#[test]
fn decoder_returns_silence() {
unsafe {
Expand Down
Loading