summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-12-30 16:37:33 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-12-30 16:37:33 (GMT)
commitf8b3c8c2ca2a51100c7b7649acf5aa90a47623bc (patch)
treeafb40c0c0f99de71562925699e5b9c5ec8b4d538
parent6666b62d6337fed6cab2ec7422423fd08ac36598 (diff)
added fix volume factor to player
-rw-r--r--player/player.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/player/player.go b/player/player.go
index 77f34a3..67e5de2 100644
--- a/player/player.go
+++ b/player/player.go
@@ -154,6 +154,7 @@ type player struct {
level *gst.Element
bus *gst.Bus
basepath string
+ volume float64
stdlog *log.Logger
dbglog *log.Logger
state State
@@ -391,7 +392,7 @@ func (p *player) createPipeline() (err error) {
return
}
- var conv1, conv2, sink *gst.Element
+ var conv1, conv2, volume, sink *gst.Element
if p.src, err = gst.ElementFactoryMake("uridecodebin", "source"); err != nil {
return
}
@@ -408,6 +409,10 @@ func (p *player) createPipeline() (err error) {
if conv2, err = gst.ElementFactoryMake("audioconvert", "conv2"); err != nil {
return
}
+ if volume, err = gst.ElementFactoryMake("volume", "volume"); err != nil {
+ return
+ }
+ volume.SetProperty("volume", p.volume)
if sink, err = gst.ElementFactoryMake("autoaudiosink", "sink"); err != nil {
return
}
@@ -416,6 +421,7 @@ func (p *player) createPipeline() (err error) {
p.pipe.Add(conv1)
p.pipe.Add(p.level)
p.pipe.Add(conv2)
+ p.pipe.Add(volume)
p.pipe.Add(sink)
sinkpad, err := conv1.GetStaticPad("sink")
@@ -430,7 +436,8 @@ func (p *player) createPipeline() (err error) {
})
conv1.Link(p.level)
p.level.Link(conv2)
- conv2.Link(sink)
+ conv2.Link(volume)
+ volume.Link(sink)
if p.bus, err = p.pipe.GetBus(); err != nil {
return
@@ -591,9 +598,10 @@ func (p *player) GetInterface() *Player {
return ch
}
-func NewPlayer(basepath string, stdlog *log.Logger, dbglog *log.Logger) (p *player, err error) {
+func NewPlayer(basepath string, volume float64, stdlog *log.Logger, dbglog *log.Logger) (p *player, err error) {
p = &player{}
p.basepath = path.Clean(basepath)
+ p.volume = volume
p.state = IDLE
p.duration = 0
if stdlog != nil {