summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-13 20:18:23 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-13 20:18:23 (GMT)
commit57d45bc46d23a8e9abbd707277425c2961a2b57d (patch)
tree60035f7983c6cb7911542befcd604829304aee59
parent50490b7942c385fa40dd5dcdc7d4d65cd1a0614d (diff)
added stdlog and dbglog
-rw-r--r--player/player.go28
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)