diff options
Diffstat (limited to 'player')
-rw-r--r-- | player/player.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/player/player.go b/player/player.go index 97d599a..95bab81 100644 --- a/player/player.go +++ b/player/player.go @@ -74,7 +74,8 @@ type Player struct { pipe *gst.Element bus *gst.Bus basepath string - log *log.Logger + stdlog *log.Logger + dbglog *log.Logger loadChan chan loadRequest playChan chan playRequest pauseChan chan pauseRequest @@ -84,25 +85,25 @@ type Player struct { func (p *Player) onMessage(msg *gst.Message) { switch msg.GetType() { case gst.MESSAGE_EOS: - p.log.Printf("GStreamer Pipeline: EOS reached!\n") + p.stdlog.Printf("GStreamer Pipeline: EOS reached!\n") p.pipe.SetState(gst.STATE_NULL) case gst.MESSAGE_WARNING: warn, _ := msg.ParseWarning() - p.log.Printf("GStreamer Pipeline Warning: %s\n", warn) + p.stdlog.Printf("GStreamer Pipeline Warning: %s\n", warn) case gst.MESSAGE_ERROR: p.pipe.SetState(gst.STATE_NULL) err, _ := msg.ParseError() - p.log.Printf("GStreamer Pipeline Error: %s\n", err) + p.stdlog.Printf("GStreamer Pipeline Error: %s\n", err) case gst.MESSAGE_ASYNC_DONE: len, ok := p.pipe.QueryDuration(gst.FORMAT_TIME) if ok { - p.log.Printf("GStreamer Pipeline: loaded file has length: %d.%d s\n", len/1000000000, len%1000000000) + p.stdlog.Printf("GStreamer Pipeline: loaded file has length: %d.%d s\n", len/1000000000, len%1000000000) } else { - p.log.Printf("GStreamer Pipeline Error: unable to query duration of file\n") + p.stdlog.Printf("GStreamer Pipeline Error: unable to query duration of file\n") } case gst.MESSAGE_STATE_CHANGED: default: - p.log.Printf("GStreamer Message: unknown type '%s'\n", msg.GetTypeName()) + p.stdlog.Printf("GStreamer Message: unknown type '%s'\n", msg.GetTypeName()) } } @@ -222,13 +223,18 @@ func (p *Player) GetInterface() *PlayerChan { return ch } -func NewPlayer(basepath string, logger *log.Logger) (p *Player, err error) { +func NewPlayer(basepath string, stdlog *log.Logger, dbglog *log.Logger) (p *Player, err error) { p = &Player{} p.basepath = path.Clean(basepath) - if logger != nil { - p.log = logger + if stdlog != nil { + p.stdlog = stdlog } else { - p.log = log.New(ioutil.Discard, "rhrd-go.player", log.LstdFlags) + p.stdlog = log.New(ioutil.Discard, "rhrd-go.player", log.LstdFlags) + } + if dbglog != nil { + p.dbglog = dbglog + } else { + p.dbglog = log.New(ioutil.Discard, "rhrd-go.player-dbg", log.LstdFlags) } p.loadChan = make(chan loadRequest) p.playChan = make(chan playRequest) |