Replace wpctl volume control with SDL_mixer VolumeMusic

Remove all PipeWire/wpctl system calls (SetDefaultSinkVolume,
listSinkIDs, listSinks, SetAllSinkVolumes, parseSinks, parseSinkLine,
Sink struct). Volume is now managed entirely through SDL_mixer's
VolumeMusic(), making audio fully system-agnostic.

Changes:
- mixer.go: delete ~170 lines of wpctl code; add SetVolume() public
  API using mix.VolumeMusic(math.Round(level * MAX_VOLUME))
- Init/Play/SwitchDevice set volume inline (they already hold the mutex)
- Play() now uses stored currentVolume instead of hardcoded MAX_VOLUME
- AudioOptions: SetAllSinkVolumes -> SetVolume
- mixer_test.go: add TestSetVolume (validation + error path coverage)
This commit is contained in:
NeilClack
2026-07-29 14:58:15 -05:00
parent 7a3b6a66b7
commit 3480e7594a
3 changed files with 62 additions and 204 deletions
+33
View File
@@ -7,6 +7,39 @@ import (
"rhemawavetech.com/rhemawave/internal/mixer"
)
func TestSetVolume(t *testing.T) {
tests := []struct {
name string
level float64
wantErr bool
}{
{"zero volume", 0.0, false},
{"half volume", 0.5, false},
{"max volume", 1.0, false},
{"above range", 1.5, true},
{"negative", -0.1, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := mixer.SetVolume(tt.level)
if tt.wantErr {
if err == nil {
t.Errorf("SetVolume(%v) = nil, want error", tt.level)
}
return
}
if err != nil {
// For valid input, failure is expected when SDL isn't initialized
// (that's fine — we're testing validation, not SDL integration)
if err.Error() != "audio mixer not initialized" {
t.Errorf("SetVolume(%v) = %v, want 'audio mixer not initialized' or nil", tt.level, err)
}
}
})
}
}
func TestConvertVolume(t *testing.T) {
tests := []struct {
name string