Exit on fatal microphone device errors
This commit is contained in:
committed by
Brandon McGinty
parent
d2e94c76b5
commit
6bf79acc6a
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -8,6 +9,7 @@ import (
|
||||
"unicode"
|
||||
|
||||
"git.stormux.org/storm/barnard/gumble/gumble"
|
||||
"git.stormux.org/storm/barnard/gumble/gumbleopenal"
|
||||
"git.stormux.org/storm/barnard/uiterm"
|
||||
"github.com/kennygrant/sanitize"
|
||||
"github.com/nsf/termbox-go"
|
||||
@@ -328,6 +330,13 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
||||
} else {
|
||||
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
|
||||
if err != nil {
|
||||
b.Tx = false
|
||||
if fatalAudioOpenError(err) {
|
||||
// A missing capture device cannot recover through normal
|
||||
// transmission controls; exit so option 1 reports it on stderr.
|
||||
b.exitWithError(fmt.Errorf("audio device initialization failed: %w", err))
|
||||
return
|
||||
}
|
||||
b.Notify("error", "me", err.Error())
|
||||
b.UpdateGeneralStatus(err.Error(), true)
|
||||
} else {
|
||||
@@ -338,6 +347,10 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
||||
}
|
||||
}
|
||||
|
||||
func fatalAudioOpenError(err error) bool {
|
||||
return errors.Is(err, gumbleopenal.ErrMic) || errors.Is(err, gumbleopenal.ErrInputDevice) || errors.Is(err, gumbleopenal.ErrOutputDevice)
|
||||
}
|
||||
|
||||
func (b *Barnard) OnMicVolumeDown(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if b.ToneTest || b.Stream == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user