]> Sergey Matveev's repositories - vors.git/blobdiff - cmd/client/main.go
Silencing of the peer
[vors.git] / cmd / client / main.go
index 620dee6289b3cde532a8ab2c3533e93e1c3cb8662cb5238dd61c62c01374e92b..f485d513ffa4fa32d2a2bec43be19b9e8d779982e3da482a72dc56459931315d 100644 (file)
@@ -42,12 +42,13 @@ import (
 )
 
 type Stream struct {
-       name  string
-       ctr   uint32
-       actr  uint32
-       muted bool
-       in    chan []byte
-       stats *Stats
+       name     string
+       ctr      uint32
+       actr     uint32
+       muted    bool
+       silenced bool
+       in       chan []byte
+       stats    *Stats
 }
 
 var (
@@ -315,10 +316,20 @@ func main() {
        if err := GUI.SetKeybinding("", gocui.KeyTab, gocui.ModNone, tabHandle); err != nil {
                log.Fatal(err)
        }
-       if err := GUI.SetKeybinding("", gocui.KeyF1, gocui.ModNone, mute); err != nil {
+       if err := GUI.SetKeybinding("", gocui.KeyF1, gocui.ModNone,
+               func(gui *gocui.Gui, v *gocui.View) error {
+                       muteToggle()
+                       return nil
+               },
+       ); err != nil {
                log.Fatal(err)
        }
-       if err := GUI.SetKeybinding("", gocui.KeyF10, gocui.ModNone, guiQuit); err != nil {
+       if err := GUI.SetKeybinding("", gocui.KeyF10, gocui.ModNone,
+               func(gui *gocui.Gui, v *gocui.View) error {
+                       Finish <- struct{}{}
+                       return gocui.ErrQuit
+               },
+       ); err != nil {
                log.Fatal(err)
        }
 
@@ -425,6 +436,9 @@ func main() {
                                                                if !ok {
                                                                        break
                                                                }
+                                                               if stream.silenced {
+                                                                       continue
+                                                               }
                                                                if _, err = io.Copy(player,
                                                                        bytes.NewReader(pcmbuf)); err != nil {
                                                                        log.Println("play:", err)