mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
fix
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -70,9 +70,8 @@ func (c *WSClient) applyAudioLevelsToMixer(levels AudioLevels) {
|
|||||||
func (c *WSClient) applyMixerGain(control string, gain float64) {
|
func (c *WSClient) applyMixerGain(control string, gain float64) {
|
||||||
normalized := clampAudioGain(gain)
|
normalized := clampAudioGain(gain)
|
||||||
if normalized <= 0 {
|
if normalized <= 0 {
|
||||||
out, err := exec.Command("amixer", "-q", "-c", "0", "sset", control, "0%").CombinedOutput()
|
if err := c.trySetMixerControl(control, "0%"); err != nil {
|
||||||
if err != nil {
|
c.log.Printf("audio-levels: amixer mute %s failed: %v", control, err)
|
||||||
c.log.Printf("audio-levels: amixer mute %s failed: %v (%s)", control, err, string(out))
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -87,8 +86,24 @@ func (c *WSClient) applyMixerGain(control string, gain float64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbArg := fmt.Sprintf("%.2fdB", db)
|
dbArg := fmt.Sprintf("%.2fdB", db)
|
||||||
out, err := exec.Command("amixer", "-q", "-c", "0", "sset", control, dbArg).CombinedOutput()
|
if err := c.trySetMixerControl(control, dbArg); err != nil {
|
||||||
if err != nil {
|
c.log.Printf("audio-levels: amixer set %s=%s failed: %v", control, dbArg, err)
|
||||||
c.log.Printf("audio-levels: amixer set %s=%s failed: %v (%s)", control, dbArg, err, string(out))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *WSClient) trySetMixerControl(control, value string) error {
|
||||||
|
// Prefer the active ALSA default route; fall back to card index for compatibility.
|
||||||
|
candidates := [][]string{
|
||||||
|
{"-q", "-D", "default", "sset", control, value},
|
||||||
|
{"-q", "-c", "0", "sset", control, value},
|
||||||
|
}
|
||||||
|
var lastErr error
|
||||||
|
for _, args := range candidates {
|
||||||
|
out, err := exec.Command("amixer", args...).CombinedOutput()
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
lastErr = fmt.Errorf("%w (%s)", err, string(out))
|
||||||
|
}
|
||||||
|
return lastErr
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user