voelin-media: fix Wayland screen capture delivering no frames at all
Measured on a real 2560x1440 Wayland desktop through the ScreenCast portal, which nothing here had ever run against: every captured frame was dropped and the viewer got nothing. Two faults, one behind the other. The mapping length came from `mapoffset + maxsize`. Those describe a mapping, which only shared memory has; a DMA-BUF's size lives in its buffer object, and this compositor leaves both fields 0 (the file descriptor and the 10240-byte stride were fine). The length was therefore 0, every map was refused, and the capture delivered nothing for as long as it ran. Derive the length from the rows the negotiated format describes, which is exactly what is read afterwards. With frames flowing, the second fault showed: reading a LINEAR DMA-BUF from this GPU's memory took 11.95 ms per frame and 19.5 CPU cores at 1440p60, against 0.27 ms and 0.41 cores for the same capture over shared memory — 44 times the time, 48 times the CPU. The guard that exists for this switches at 6.0 ns per pixel and the DMA-BUF path only reaches 3.24, so it never fired. Put the threshold between the two measurements, an order of magnitude above the shared-memory figure so a GPU whose buffers the CPU can read keeps them. After both: 2560x1440 at 60.0 fps on 0.55 cores, no dropped frames, the bitrate honoured. A DMA-BUF that cannot be mapped at all now also falls back to shared memory after a few failures instead of dropping frames forever. `stream bench` was reporting the layer size from --res, which is not what a real source encodes; it now prints the size that was really encoded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1f571055fe
commit
e5789e495e
2 files changed
+56
-4
No files matched your search
@@ -423,7 +423,13 @@ fn bench(args: BenchArgs) -> Result<()> {
|
||||
let frames = b.frames - a.frames;
|
||||
output_frames += frames;
|
||||
let spec = layers.iter().find(|l| l.id == *id);
|
||||
let size = spec.map_or((width, height), |l| l.output_size(width, height));
|
||||
let layer_stats = stats.layers.iter().find(|l| l.id == *id);
|
||||
// What was really encoded: with a real source the size comes from the
|
||||
// capture, not from --res.
|
||||
let size = match layer_stats.filter(|l| l.width > 0) {
|
||||
Some(l) => (l.width, l.height),
|
||||
None => spec.map_or((width, height), |l| l.output_size(width, height)),
|
||||
};
|
||||
let dropped = |s: &Sample| s.dropped.iter().find(|d| d.0 == *id).map_or(0, |d| d.1);
|
||||
let layer = stats.layers.iter().find(|l| l.id == *id);
|
||||
println!(
|
||||
|
||||
Reference in new issue
Block a user