Persist microphone mute and volume settings
This commit is contained in:
1 parent
aa38c99aab
commit
4497d41077
6 files changed
+28
-6
No files matched your search
@@ -265,6 +265,13 @@ func (c *Config) SetMicVolume(v float32) {
|
||||
c.config.MicVolume = &t
|
||||
}
|
||||
|
||||
func (c *Config) GetMicVolume() float32 {
|
||||
if c.config.MicVolume == nil {
|
||||
return 1.0
|
||||
}
|
||||
return *c.config.MicVolume
|
||||
}
|
||||
|
||||
func (c *Config) GetHotkeys() *Hotkeys {
|
||||
return c.config.Hotkeys
|
||||
}
|
||||
|
||||
@@ -50,6 +50,17 @@ func TestMakeHostPortHandlesIPv6AndMalformedAddress(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Regression: a stored zero mic volume was treated as an uninitialized value,
|
||||
// so a persisted mute became full volume after reconnecting.
|
||||
func TestMicVolumeAllowsPersistedMute(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "barnard.toml")
|
||||
cfg := NewConfig(&path)
|
||||
cfg.SetMicVolume(0)
|
||||
if got := cfg.GetMicVolume(); got != 0 {
|
||||
t.Fatalf("got %v, want mute", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigUsesHomeEnvironmentForDefaultPath(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Setenv("HOME", dir)
|
||||
|
||||
Reference in new issue
Block a user