Improve sound initialization.
This commit is contained in:
1 parent
46dc520854
commit
b887f6ea95
4 files changed
+14
-11
No files matched your search
@@ -75,9 +75,11 @@ server or ALSA device. The [PulseAudio](tools/configure_pulse.sh) and
|
|||||||
[PipeWire](tools/configure_pipewire.sh) configuration scripts are included for
|
[PipeWire](tools/configure_pipewire.sh) configuration scripts are included for
|
||||||
systems that need root audio access.
|
systems that need root audio access.
|
||||||
|
|
||||||
The default sound driver tries the user session first, then the system-wide
|
The default sound driver tries the user session first, then `/tmp/pulse.sock`
|
||||||
PulseAudio-compatible socket at `/run/pulse/native`, including when provided by
|
created by the PipeWire configuration script, then the system-wide
|
||||||
PipeWire. Set `PULSE_SERVER` to select a different socket or server explicitly.
|
PulseAudio-compatible socket at `/run/pulse/native`. Set `PULSE_SERVER` to select
|
||||||
|
a different socket or server explicitly. The sound driver does not read
|
||||||
|
PulseAudio's `client.conf`.
|
||||||
Speech output uses Speech Dispatcher's own audio configuration.
|
Speech output uses Speech Dispatcher's own audio configuration.
|
||||||
|
|
||||||
### X11 terminal
|
### X11 terminal
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import (
|
|||||||
|
|
||||||
func open_pulse(s *Service, _ string) error {
|
func open_pulse(s *Service, _ string) error {
|
||||||
options := []pulse.ClientOption{pulse.ClientApplicationName("Fenrir sounds"), pulse.ClientTimeout(500 * time.Millisecond)}
|
options := []pulse.ClientOption{pulse.ClientApplicationName("Fenrir sounds"), pulse.ClientTimeout(500 * time.Millisecond)}
|
||||||
// Try the invoking user's session, then the system-wide service, unless
|
// Try the invoking user's session, then the bundled PipeWire helper's
|
||||||
// PULSE_SERVER explicitly selects a server.
|
// socket and the system-wide service, unless PULSE_SERVER selects a server.
|
||||||
options = append(options, pulse.ClientServerString(Server(os.Getenv("PULSE_SERVER"), os.Getenv("SUDO_UID"))))
|
options = append(options, pulse.ClientServerString(Server(os.Getenv("PULSE_SERVER"), os.Getenv("SUDO_UID"))))
|
||||||
client, err := pulse.NewClient(options...)
|
client, err := pulse.NewClient(options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ func (s *Service) Set_volume(volume float64) {
|
|||||||
s.volume.Store(math.Float32bits(float32(volume)))
|
s.volume.Store(math.Float32bits(float32(volume)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server returns PulseAudio protocol addresses in connection order. PipeWire's
|
// Server returns PulseAudio protocol addresses in connection order. The bundled
|
||||||
// PulseAudio service can expose the system-wide /run/pulse/native socket.
|
// PipeWire helper exposes /tmp/pulse.sock for console clients; system-wide
|
||||||
|
// PulseAudio services can expose /run/pulse/native.
|
||||||
// The client library tries each address, including after authentication errors.
|
// The client library tries each address, including after authentication errors.
|
||||||
func Server(explicit, sudoUID string) string {
|
func Server(explicit, sudoUID string) string {
|
||||||
if explicit != "" {
|
if explicit != "" {
|
||||||
@@ -99,7 +100,7 @@ func Server(explicit, sudoUID string) string {
|
|||||||
} else if runtimeDir == "" {
|
} else if runtimeDir == "" {
|
||||||
runtimeDir = fmt.Sprintf("/run/user/%d", os.Getuid())
|
runtimeDir = fmt.Sprintf("/run/user/%d", os.Getuid())
|
||||||
}
|
}
|
||||||
return "unix:" + filepath.Join(runtimeDir, "pulse/native") + " unix:/run/pulse/native"
|
return "unix:" + filepath.Join(runtimeDir, "pulse/native") + " unix:/tmp/pulse.sock unix:/run/pulse/native"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play only replaces a mailbox pointer. Startup has its own slot so initial
|
// Play only replaces a mailbox pointer. Startup has its own slot so initial
|
||||||
|
|||||||
@@ -270,11 +270,11 @@ func TestSoundServerFollowsExplicitAndSudoSession(t *testing.T) {
|
|||||||
if got := Server("unix:/tmp/example-pulse", "1000"); got != "unix:/tmp/example-pulse" {
|
if got := Server("unix:/tmp/example-pulse", "1000"); got != "unix:/tmp/example-pulse" {
|
||||||
t.Fatal(got)
|
t.Fatal(got)
|
||||||
}
|
}
|
||||||
if got := Server("", "1000"); got != "unix:/run/user/1000/pulse/native unix:/run/pulse/native" {
|
if got := Server("", "1000"); got != "unix:/run/user/1000/pulse/native unix:/tmp/pulse.sock unix:/run/pulse/native" {
|
||||||
t.Fatal(got)
|
t.Fatal(got)
|
||||||
}
|
}
|
||||||
for _, uid := range []string{"", "invalid", "../other"} {
|
for _, uid := range []string{"", "invalid", "../other"} {
|
||||||
if got := Server("", uid); got != "unix:/run/user/2000/pulse/native unix:/run/pulse/native" {
|
if got := Server("", uid); got != "unix:/run/user/2000/pulse/native unix:/tmp/pulse.sock unix:/run/pulse/native" {
|
||||||
t.Fatal(got)
|
t.Fatal(got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ func TestSoundServerFollowsExplicitAndSudoSession(t *testing.T) {
|
|||||||
|
|
||||||
func TestSoundServerWithoutRuntimeDirectoryUsesCurrentUserAndSystemFallback(t *testing.T) {
|
func TestSoundServerWithoutRuntimeDirectoryUsesCurrentUserAndSystemFallback(t *testing.T) {
|
||||||
t.Setenv("XDG_RUNTIME_DIR", "")
|
t.Setenv("XDG_RUNTIME_DIR", "")
|
||||||
want := fmt.Sprintf("unix:/run/user/%d/pulse/native unix:/run/pulse/native", os.Getuid())
|
want := fmt.Sprintf("unix:/run/user/%d/pulse/native unix:/tmp/pulse.sock unix:/run/pulse/native", os.Getuid())
|
||||||
if got := Server("", ""); got != want {
|
if got := Server("", ""); got != want {
|
||||||
t.Fatalf("Server() = %q, want %q", got, want)
|
t.Fatalf("Server() = %q, want %q", got, want)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user