Skip to content

Commit 7770641

Browse files
authored
Fix small padding invisible to the pacer (algesten#1020)
Padding smaller than the 800-byte average size divided to zero fake packets, so queue_state_padding() returned None and the pacer never scheduled it. Round up so any nonzero padding stays visible to the pacer.
1 parent d7368c8 commit 7770641

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
* Fix small padding invisible to the pacer #1020
34
* Fix H.264 negotiation: accept a negotiable (downgradable) level and recognize the Constrained High profile #1016
45
* Expose the latest send queue information on `StreamTx` #1005
56
* Fix VP9 non-flexible SS advertising a bogus R=0 GOF for single-layer streams #999

src/streams/send.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ impl StreamTx {
11341134
const AVERAGE_PADDING_PACKET_SIZE: usize = 800;
11351135
const FAKE_PADDING_DURATION_MILLIS: usize = 5;
11361136

1137-
let fake_packets = self.padding / AVERAGE_PADDING_PACKET_SIZE;
1137+
let fake_packets = self.padding.div_ceil(AVERAGE_PADDING_PACKET_SIZE);
11381138
let fake_millis = fake_packets * FAKE_PADDING_DURATION_MILLIS;
11391139
let fake_duration = Duration::from_millis(fake_millis as u64);
11401140

@@ -1296,4 +1296,17 @@ mod test {
12961296
stream.reset_buffers();
12971297
assert!(stream.queue_info().is_none());
12981298
}
1299+
1300+
#[test]
1301+
fn sub_average_padding_is_visible_to_the_pacer() {
1302+
let mut stream = StreamTx::new(42.into(), None, MidRid(Mid::from("0"), None), false, 1200);
1303+
stream.padding = 240;
1304+
1305+
let snapshot = stream
1306+
.queue_state_padding(Instant::now())
1307+
.expect("nonzero padding must produce a queue snapshot");
1308+
1309+
assert_eq!(snapshot.byte_size, 240);
1310+
assert_eq!(snapshot.packet_count, 1);
1311+
}
12991312
}

0 commit comments

Comments
 (0)