Improve sound server fallback and speech acknowledgement handling
Try the invoking user session followed by /run/pulse/native for sound cues, while preserving an explicit PULSE_SERVER override. Resolve the user socket from SUDO_UID, XDG_RUNTIME_DIR, or the current UID, and document the fallback and Speech Dispatcher audio configuration. Allow five seconds for Speech Dispatcher command acknowledgements so large voice catalog queries can finish without premature failures. Add regression coverage for socket selection and delayed replies. Include cpu-usage.patch as a standalone patch artifact containing Python remote registry permission and registration failure handling changes. The patch is stored without applying it to the Python sources. Validation: go test ./internal/sound ./internal/speech -count=1 passed with GOCACHE=/tmp/cthulhu-go-cache and GOPROXY=off outside the sandbox to permit local Unix sockets. source diff whitespace checks passed. The staged patch has whitespace warnings from preserved blank context lines; its contents are retained unchanged. Live audio and keyboard behavior were not tested.
This commit is contained in:
1 parent
60abcc37d9
commit
db6955f5b7
7 files changed
+177
-10
No files matched your search
@@ -23,6 +23,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -84,14 +86,20 @@ func (s *Service) Set_volume(volume float64) {
|
||||
s.volume.Store(math.Float32bits(float32(volume)))
|
||||
}
|
||||
|
||||
// Server returns PulseAudio protocol addresses in connection order. PipeWire's
|
||||
// PulseAudio service can expose the system-wide /run/pulse/native socket.
|
||||
// The client library tries each address, including after authentication errors.
|
||||
func Server(explicit, sudoUID string) string {
|
||||
if explicit != "" {
|
||||
return explicit
|
||||
}
|
||||
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
|
||||
if uid, err := strconv.ParseUint(sudoUID, 10, 32); err == nil {
|
||||
return fmt.Sprintf("unix:/run/user/%d/pulse/native", uid)
|
||||
runtimeDir = fmt.Sprintf("/run/user/%d", uid)
|
||||
} else if runtimeDir == "" {
|
||||
runtimeDir = fmt.Sprintf("/run/user/%d", os.Getuid())
|
||||
}
|
||||
return ""
|
||||
return "unix:" + filepath.Join(runtimeDir, "pulse/native") + " unix:/run/pulse/native"
|
||||
}
|
||||
|
||||
// Play only replaces a mailbox pointer. Startup has its own slot so initial
|
||||
|
||||
Reference in new issue
Block a user