internal/pipewire: fail on unacknowledged proxies

These proxies (with special cases documented in the implementation) are only safe for use after acknowledgement from the server.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-12-02 21:17:22 +09:00
parent e7a665e043
commit 32fb137bb2

View File

@@ -18,6 +18,7 @@ import (
"encoding/binary"
"fmt"
"io"
"maps"
"net"
"slices"
"strconv"
@@ -424,6 +425,14 @@ func (e DanglingFilesError) Error() string {
return "received " + strconv.Itoa(len(e)) + " dangling files"
}
// An UnacknowledgedProxyError holds newly allocated proxy ids that the server failed
// to acknowledge after an otherwise successful [Context.Roundtrip].
type UnacknowledgedProxyError []Int
func (e UnacknowledgedProxyError) Error() string {
return "server did not acknowledge " + strconv.Itoa(len(e)) + " proxies"
}
// roundtripSyncID is the id passed to Context.coreSync during a [Context.Roundtrip].
const roundtripSyncID = 0
@@ -489,6 +498,10 @@ func (ctx *Context) Roundtrip() (err error) {
if len(ctx.receivedFiles) < receivedHeaderFiles {
return DanglingFilesError(ctx.receivedFiles[len(ctx.receivedFiles)-receivedHeaderFiles:])
}
if len(ctx.pendingIds) != 0 {
return UnacknowledgedProxyError(slices.Collect(maps.Keys(ctx.pendingIds)))
}
return
}