summaryrefslogtreecommitdiff
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/player.go60
1 files changed, 30 insertions, 30 deletions
diff --git a/player/player.go b/player/player.go
index e60b416..77f34a3 100644
--- a/player/player.go
+++ b/player/player.go
@@ -148,7 +148,7 @@ type pStateChangeCB struct {
userdata interface{}
}
-type Player struct {
+type player struct {
pipe *gst.Pipeline
src *gst.Element
level *gst.Element
@@ -173,7 +173,7 @@ type Player struct {
stateChangeChan chan State
}
-func (p *Player) changeState(new State) {
+func (p *player) changeState(new State) {
p.state = new
p.stateChangeChan <- new
if new == IDLE {
@@ -181,7 +181,7 @@ func (p *Player) changeState(new State) {
}
}
-func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) {
+func (p *player) onMessage(bus *gst.Bus, msg *gst.Message) {
switch msg.GetType() {
case gst.MESSAGE_EOS:
p.pipe.SetState(gst.STATE_NULL)
@@ -233,7 +233,7 @@ func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) {
}
}
-func (p *Player) load(cart, cut uint) (resp loadResult) {
+func (p *player) load(cart, cut uint) (resp loadResult) {
filename := path.Join(p.basepath, fmt.Sprintf("%06d_%03d.wav", cart, cut))
var file *os.File
@@ -262,13 +262,13 @@ func (p *Player) load(cart, cut uint) (resp loadResult) {
return
}
-func (p *Player) unload() (resp unloadResult) {
+func (p *player) unload() (resp unloadResult) {
p.pipe.SetState(gst.STATE_NULL)
p.changeState(IDLE)
return
}
-func (p *Player) play() (resp playResult) {
+func (p *player) play() (resp playResult) {
if p.state != PAUSED {
resp.err = fmt.Errorf("player: no file loaded")
return
@@ -278,7 +278,7 @@ func (p *Player) play() (resp playResult) {
return
}
-func (p *Player) pause() (resp pauseResult) {
+func (p *player) pause() (resp pauseResult) {
if p.state != PLAYING {
resp.err = fmt.Errorf("player: not playing")
return
@@ -288,7 +288,7 @@ func (p *Player) pause() (resp pauseResult) {
return
}
-func (p *Player) playPause() (resp playPauseResult) {
+func (p *player) playPause() (resp playPauseResult) {
switch p.state {
case IDLE, PAUSED:
p.pipe.SetState(gst.STATE_PLAYING)
@@ -300,7 +300,7 @@ func (p *Player) playPause() (resp playPauseResult) {
return
}
-func (p *Player) stop() (resp stopResult) {
+func (p *player) stop() (resp stopResult) {
switch p.state {
case IDLE:
p.pipe.SetState(gst.STATE_NULL)
@@ -313,7 +313,7 @@ func (p *Player) stop() (resp stopResult) {
return
}
-func (p *Player) seek(pos float64) (resp seekResult) {
+func (p *player) seek(pos float64) (resp seekResult) {
postime := int64(float64(p.duration) * pos)
switch p.state {
case PLAYING, PAUSED:
@@ -322,12 +322,12 @@ func (p *Player) seek(pos float64) (resp seekResult) {
return
}
-func (p *Player) addUpdateHandler(callback UpdateCB, userdata interface{}) (resp addUpdateHandlerResult) {
+func (p *player) addUpdateHandler(callback UpdateCB, userdata interface{}) (resp addUpdateHandlerResult) {
p.updateCBs = append(p.updateCBs, &pUpdateCB{callback, userdata})
return
}
-func (p *Player) sendUpdate(duration time.Duration, pos time.Duration, meter Meter) {
+func (p *player) sendUpdate(duration time.Duration, pos time.Duration, meter Meter) {
for _, cb := range p.updateCBs {
if cb.cb != nil {
if keep := cb.cb(duration, pos, meter, cb.userdata); !keep {
@@ -338,12 +338,12 @@ func (p *Player) sendUpdate(duration time.Duration, pos time.Duration, meter Met
return
}
-func (p *Player) addStateChangeHandler(callback StateChangeCB, userdata interface{}) (resp addStateChangeHandlerResult) {
+func (p *player) addStateChangeHandler(callback StateChangeCB, userdata interface{}) (resp addStateChangeHandlerResult) {
p.stateChangeCBs = append(p.stateChangeCBs, &pStateChangeCB{callback, userdata})
return
}
-func (p *Player) sendStateChange(s State) {
+func (p *player) sendStateChange(s State) {
for _, cb := range p.stateChangeCBs {
if cb.cb != nil {
if keep := cb.cb(s, cb.userdata); !keep {
@@ -354,7 +354,7 @@ func (p *Player) sendStateChange(s State) {
return
}
-func (p *Player) dispatchRequests() {
+func (p *player) dispatchRequests() {
p.bus.AddSignalWatch()
p.bus.Connect("message", func(bus *gst.Bus, msg *gst.Message) { p.onMessage(bus, msg) })
@@ -386,7 +386,7 @@ func (p *Player) dispatchRequests() {
}
}
-func (p *Player) createPipeline() (err error) {
+func (p *player) createPipeline() (err error) {
if p.pipe, err = gst.PipelineNew("rhlibrary"); err != nil {
return
}
@@ -441,7 +441,7 @@ func (p *Player) createPipeline() (err error) {
// *********************************************************
// Public Interface
-type PlayerChan struct {
+type Player struct {
load chan<- loadRequest
unload chan<- unloadRequest
play chan<- playRequest
@@ -453,7 +453,7 @@ type PlayerChan struct {
addStateChangeHandler chan<- addStateChangeHandlerRequest
}
-func (p *PlayerChan) Load(cart, cut uint) error {
+func (p *Player) Load(cart, cut uint) error {
resCh := make(chan loadResult)
req := loadRequest{}
req.cart = cart
@@ -468,7 +468,7 @@ func (p *PlayerChan) Load(cart, cut uint) error {
return nil
}
-func (p *PlayerChan) Unload() error {
+func (p *Player) Unload() error {
resCh := make(chan unloadResult)
req := unloadRequest{}
req.response = resCh
@@ -481,7 +481,7 @@ func (p *PlayerChan) Unload() error {
return nil
}
-func (p *PlayerChan) Play() error {
+func (p *Player) Play() error {
resCh := make(chan playResult)
req := playRequest{}
req.response = resCh
@@ -494,7 +494,7 @@ func (p *PlayerChan) Play() error {
return nil
}
-func (p *PlayerChan) Pause() error {
+func (p *Player) Pause() error {
resCh := make(chan pauseResult)
req := pauseRequest{}
req.response = resCh
@@ -507,7 +507,7 @@ func (p *PlayerChan) Pause() error {
return nil
}
-func (p *PlayerChan) PlayPause() error {
+func (p *Player) PlayPause() error {
resCh := make(chan playPauseResult)
req := playPauseRequest{}
req.response = resCh
@@ -520,7 +520,7 @@ func (p *PlayerChan) PlayPause() error {
return nil
}
-func (p *PlayerChan) Stop() error {
+func (p *Player) Stop() error {
resCh := make(chan stopResult)
req := stopRequest{}
req.response = resCh
@@ -533,7 +533,7 @@ func (p *PlayerChan) Stop() error {
return nil
}
-func (p *PlayerChan) Seek(pos float64) error {
+func (p *Player) Seek(pos float64) error {
resCh := make(chan seekResult)
req := seekRequest{}
req.pos = pos
@@ -547,7 +547,7 @@ func (p *PlayerChan) Seek(pos float64) error {
return nil
}
-func (p *PlayerChan) AddUpdateHandler(callback UpdateCB, userdata interface{}) error {
+func (p *Player) AddUpdateHandler(callback UpdateCB, userdata interface{}) error {
resCh := make(chan addUpdateHandlerResult)
req := addUpdateHandlerRequest{}
req.callback = callback
@@ -562,7 +562,7 @@ func (p *PlayerChan) AddUpdateHandler(callback UpdateCB, userdata interface{}) e
return nil
}
-func (p *PlayerChan) AddStateChangeHandler(callback StateChangeCB, userdata interface{}) error {
+func (p *Player) AddStateChangeHandler(callback StateChangeCB, userdata interface{}) error {
resCh := make(chan addStateChangeHandlerResult)
req := addStateChangeHandlerRequest{}
req.callback = callback
@@ -577,8 +577,8 @@ func (p *PlayerChan) AddStateChangeHandler(callback StateChangeCB, userdata inte
return nil
}
-func (p *Player) GetInterface() *PlayerChan {
- ch := &PlayerChan{}
+func (p *player) GetInterface() *Player {
+ ch := &Player{}
ch.load = p.loadChan
ch.unload = p.unloadChan
ch.play = p.playChan
@@ -591,8 +591,8 @@ func (p *Player) GetInterface() *PlayerChan {
return ch
}
-func NewPlayer(basepath string, stdlog *log.Logger, dbglog *log.Logger) (p *Player, err error) {
- p = &Player{}
+func NewPlayer(basepath string, stdlog *log.Logger, dbglog *log.Logger) (p *player, err error) {
+ p = &player{}
p.basepath = path.Clean(basepath)
p.state = IDLE
p.duration = 0