aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/outcome/sppulse.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-11 21:04:02 +0900
committerOphestra <cat@gensokyo.uk>2026-03-11 21:04:02 +0900
commit5c540f90aa5ac069a370cbef0ddd81fa268b43c5 (patch)
treea57f2347c1c797b649248068aa00b4b6a28ddc43 /internal/outcome/sppulse.go
parent1e8ac5f68ef6911c278b4c48722a1924d996206c (diff)
internal/outcome: improve doc comments
This improves readability on smaller displays. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/outcome/sppulse.go')
-rw-r--r--internal/outcome/sppulse.go49
1 files changed, 38 insertions, 11 deletions
diff --git a/internal/outcome/sppulse.go b/internal/outcome/sppulse.go
index e86fb3f8..386800bb 100644
--- a/internal/outcome/sppulse.go
+++ b/internal/outcome/sppulse.go
@@ -20,6 +20,7 @@ const pulseCookieSizeMax = 1 << 8
func init() { gob.Register(new(spPulseOp)) }
// spPulseOp exports the PulseAudio server to the container.
+//
// Runs after spRuntimeOp.
type spPulseOp struct {
// PulseAudio cookie data, populated during toSystem if a cookie is present.
@@ -37,24 +38,40 @@ func (s *spPulseOp) toSystem(state *outcomeStateSys) error {
if _, err := state.k.stat(pulseRuntimeDir.String()); err != nil {
if !errors.Is(err, fs.ErrNotExist) {
- return &hst.AppError{Step: fmt.Sprintf("access PulseAudio directory %q", pulseRuntimeDir), Err: err}
+ return &hst.AppError{Step: fmt.Sprintf(
+ "access PulseAudio directory %q",
+ pulseRuntimeDir,
+ ), Err: err}
}
- return newWithMessageError(fmt.Sprintf("PulseAudio directory %q not found", pulseRuntimeDir), err)
+ return newWithMessageError(fmt.Sprintf(
+ "PulseAudio directory %q not found",
+ pulseRuntimeDir,
+ ), err)
}
if fi, err := state.k.stat(pulseSocket.String()); err != nil {
if !errors.Is(err, fs.ErrNotExist) {
- return &hst.AppError{Step: fmt.Sprintf("access PulseAudio socket %q", pulseSocket), Err: err}
+ return &hst.AppError{Step: fmt.Sprintf(
+ "access PulseAudio socket %q",
+ pulseSocket,
+ ), Err: err}
}
- return newWithMessageError(fmt.Sprintf("PulseAudio directory %q found but socket does not exist", pulseRuntimeDir), err)
+ return newWithMessageError(fmt.Sprintf(
+ "PulseAudio directory %q found but socket does not exist",
+ pulseRuntimeDir,
+ ), err)
} else {
if m := fi.Mode(); m&0o006 != 0o006 {
- return newWithMessage(fmt.Sprintf("unexpected permissions on %q: %s", pulseSocket, m))
+ return newWithMessage(fmt.Sprintf(
+ "unexpected permissions on %q: %s",
+ pulseSocket, m,
+ ))
}
}
- // pulse socket is world writable and its parent directory DAC permissions prevents access;
- // hard link to target-executable share directory to grant access
+ // PulseAudio socket is world writable and its parent directory DAC
+ // permissions prevents access. Hard link to target-executable share
+ // directory to grant access
state.sys.Link(pulseSocket, state.runtime().Append("pulse"))
// load up to pulseCookieSizeMax bytes of pulse cookie for transmission to shim
@@ -62,7 +79,13 @@ func (s *spPulseOp) toSystem(state *outcomeStateSys) error {
return err
} else if a != nil {
s.Cookie = new([pulseCookieSizeMax]byte)
- if s.CookieSize, err = loadFile(state.msg, state.k, "PulseAudio cookie", a.String(), s.Cookie[:]); err != nil {
+ if s.CookieSize, err = loadFile(
+ state.msg,
+ state.k,
+ "PulseAudio cookie",
+ a.String(),
+ s.Cookie[:],
+ ); err != nil {
return err
}
} else {
@@ -101,8 +124,9 @@ func (s *spPulseOp) commonPaths(state *outcomeState) (pulseRuntimeDir, pulseSock
return
}
-// discoverPulseCookie attempts to discover the pathname of the PulseAudio cookie of the current user.
-// If both returned pathname and error are nil, the cookie is likely unavailable and can be silently skipped.
+// discoverPulseCookie attempts to discover the pathname of the PulseAudio
+// cookie of the current user. If both returned pathname and error are nil, the
+// cookie is likely unavailable and can be silently skipped.
func discoverPulseCookie(k syscallDispatcher) (*check.Absolute, error) {
const paLocateStep = "locate PulseAudio cookie"
@@ -186,7 +210,10 @@ func loadFile(
&os.PathError{Op: "stat", Path: pathname, Err: syscall.ENOMEM},
)
} else if s < int64(n) {
- msg.Verbosef("%s at %q is %d bytes shorter than expected", description, pathname, int64(n)-s)
+ msg.Verbosef(
+ "%s at %q is %d bytes shorter than expected",
+ description, pathname, int64(n)-s,
+ )
} else {
msg.Verbosef("loading %d bytes from %q", n, pathname)
}