Skip to content

Commit f182ef3

Browse files
committed
Restore direct VA-API DMA-BUF import
1 parent c6f5e63 commit f182ef3

2 files changed

Lines changed: 9 additions & 26 deletions

File tree

internal/airplay/capture.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -734,26 +734,15 @@ func pipeWireVideoSourceStage(fd int, nodeID uint32, fps int, copyPortalBuffers
734734
fmt.Sprintf("keepalive-time=%d", frameIntervalMillis(fps)),
735735
}
736736
if copyPortalBuffers {
737-
// The compositor and pipewiresrc's keepalive path both retain the latest
738-
// GstBuffer. With a small portal pool that can keep every PipeWire buffer
739-
// checked out and freeze screencopy. Copying here returns the portal buffer
740-
// as soon as pipewiresrc pulls it while downstream retains only the copy.
737+
// The software path cannot import a portal DMA-BUF through VA-API. Copy
738+
// immediately so downstream never retains a PipeWire-owned buffer.
741739
stage = append(stage, "always-copy=true")
742740
}
743741
return stage
744742
}
745743

746744
func vaapiVideoImportStages() []gstStage {
747-
// Force a fresh VA surface even when the portal's DMA-BUF already satisfies
748-
// downstream caps, then download it into system memory. The forced-live
749-
// compositor may retain its latest input; retaining the portal DMA-BUF would
750-
// eventually exhaust PipeWire's pool and repeat one stale capture timestamp.
751-
return []gstStage{
752-
{"vapostproc", "disable-passthrough=true"},
753-
// An unfeatured raw caps filter means system memory while leaving the
754-
// pixel format negotiable, preserving 10-bit portal input for HEVC.
755-
{"video/x-raw"},
756-
}
745+
return []gstStage{{"vapostproc"}}
757746
}
758747

759748
func waylandVideoInputStages(fd int, nodeID uint32, fps int, useVAAPI bool) (gstStage, []gstStage) {

internal/airplay/capture_test.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,9 @@ func TestPipeWireVideoSourceCopiesPortalBuffersForSoftwareConversion(t *testing.
390390
}
391391
}
392392

393-
func TestVAAPIPostprocCopiesPortalDMABufferToSystemMemory(t *testing.T) {
393+
func TestVAAPIPostprocReceivesOriginalPortalDMABuffer(t *testing.T) {
394394
got := vaapiVideoImportStages()
395-
want := []gstStage{
396-
{"vapostproc", "disable-passthrough=true"},
397-
{"video/x-raw"},
398-
}
395+
want := []gstStage{{"vapostproc"}}
399396
if !reflect.DeepEqual(got, want) {
400397
t.Fatalf("VA-API import stages = %v, want %v", got, want)
401398
}
@@ -409,13 +406,10 @@ func TestWaylandVideoInputStagesPreservePortalBufferOwnership(t *testing.T) {
409406
wantImports []gstStage
410407
}{
411408
{
412-
name: "VA-API imports before system-memory copy",
413-
useVAAPI: true,
414-
wantSource: gstStage{"pipewiresrc", "fd=3", "path=42", "do-timestamp=true", "keepalive-time=33"},
415-
wantImports: []gstStage{
416-
{"vapostproc", "disable-passthrough=true"},
417-
{"video/x-raw"},
418-
},
409+
name: "VA-API imports original portal buffer",
410+
useVAAPI: true,
411+
wantSource: gstStage{"pipewiresrc", "fd=3", "path=42", "do-timestamp=true", "keepalive-time=33"},
412+
wantImports: []gstStage{{"vapostproc"}},
419413
},
420414
{
421415
name: "software conversion copies portal buffer",

0 commit comments

Comments
 (0)