Remove errors from wyoming server handlers

This commit is contained in:
Alex X
2025-04-24 18:32:42 +03:00
parent 518cae1476
commit 890fd78a6a
4 changed files with 14 additions and 23 deletions

View File

@@ -93,19 +93,13 @@ func handle(srv *wyoming.Server, mode string, conn net.Conn) {
log.Trace().Msgf("[wyoming] %s connected", addr)
var err error
switch mode {
case "mic":
err = srv.HandleMic(conn)
srv.HandleMic(conn)
case "snd":
err = srv.HandleSnd(conn)
srv.HandleSnd(conn)
default:
err = srv.Handle(conn)
}
if err != nil {
log.Error().Msgf("[wyoming] %s error: %s", addr, err)
srv.Handle(conn)
}
log.Trace().Msgf("[wyoming] %s disconnected", addr)

View File

@@ -7,7 +7,7 @@ import (
"github.com/AlexxIT/go2rtc/pkg/core"
)
func (s *Server) HandleMic(conn net.Conn) error {
func (s *Server) HandleMic(conn net.Conn) {
defer conn.Close()
var closed core.Waiter
@@ -26,10 +26,10 @@ func (s *Server) HandleMic(conn net.Conn) error {
mic.RemoteAddr = api.conn.RemoteAddr().String()
if err := s.MicHandler(mic); err != nil {
return err
s.Error("mic error: %s", err)
return
}
defer mic.Stop()
return closed.Wait()
_ = closed.Wait()
_ = mic.Stop()
}

View File

@@ -37,7 +37,7 @@ func (s *Server) Serve(l net.Listener) error {
}
}
func (s *Server) Handle(conn net.Conn) error {
func (s *Server) Handle(conn net.Conn) {
api := NewAPI(conn)
sat := newSatellite(api, s)
defer sat.Close()
@@ -45,7 +45,7 @@ func (s *Server) Handle(conn net.Conn) error {
for {
evt, err := api.ReadEvent()
if err != nil {
return err
return
}
switch evt.Type {

View File

@@ -1,12 +1,11 @@
package wyoming
import (
"io"
"net"
"time"
)
func (s *Server) HandleSnd(conn net.Conn) error {
func (s *Server) HandleSnd(conn net.Conn) {
defer conn.Close()
var snd []byte
@@ -15,10 +14,7 @@ func (s *Server) HandleSnd(conn net.Conn) error {
for {
evt, err := api.ReadEvent()
if err != nil {
if err == io.EOF {
return nil
}
return err
return
}
s.Trace("event: %s data: %s payload: %d", evt.Type, evt.Data, len(evt.Payload))
@@ -33,7 +29,8 @@ func (s *Server) HandleSnd(conn net.Conn) error {
time.Sleep(time.Second) // some extra delay before close
})
if err = s.SndHandler(prod); err != nil {
return err
s.Error("snd error: %s", err)
return
}
}
}