allow no-sound mode in case of audio player creation error
This commit is contained in:
parent
0a88bd3727
commit
36f684133c
|
@ -21,7 +21,11 @@ func NewAudioPlayer() *AudioPlayer {
|
|||
|
||||
player, err := oto.NewPlayer(44100, 2, 2, 8192)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
// it is expected to fail when some of the system
|
||||
// libraries are not available (e.g. libasound2)
|
||||
// it is not the main functionality of the application,
|
||||
// so we allow startup in no-sound mode
|
||||
return nil
|
||||
}
|
||||
|
||||
return &AudioPlayer{
|
||||
|
|
|
@ -74,7 +74,7 @@ func (t *Trigger) Execute(sample *Sample) {
|
|||
fmt.Print(console.BellCharacter)
|
||||
}
|
||||
|
||||
if t.actions.sound {
|
||||
if t.actions.sound && t.player != nil {
|
||||
t.player.Beep()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue