mirror of https://bitbucket.org/ausocean/av.git
revid: move initialisation of revids netsender up higher in New so that we don't get nil pointer deference
This commit is contained in:
parent
e6d0ee035e
commit
0c2ccf55fa
|
@ -99,7 +99,7 @@ const (
|
|||
defaultFramesPerClip = 1
|
||||
defaultVerticalFlip = No
|
||||
defaultHorizontalFlip = No
|
||||
httpFramesPerClip = 25
|
||||
httpFramesPerClip = 7
|
||||
defaultInputCodec = H264
|
||||
defaultVerbosity = No
|
||||
)
|
||||
|
|
|
@ -31,7 +31,6 @@ package revid
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -116,13 +115,13 @@ type Revid struct {
|
|||
// an error if construction of the new instance was not successful.
|
||||
func New(c Config, ns *netsender.Sender) (*Revid, error) {
|
||||
var r Revid
|
||||
r.ns = ns
|
||||
err := r.reset(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.ringBuffer = ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout)
|
||||
r.outputChan = make(chan []byte, outputChanSize)
|
||||
r.ns = ns
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
|
@ -297,7 +296,6 @@ func (r *Revid) packClips() {
|
|||
// TODO: This is temporary, need to work out how to make this work
|
||||
// for cases when there is not packetisation.
|
||||
case frame := <-r.encoder.Stream():
|
||||
fmt.Println("got frame")
|
||||
lenOfFrame := len(frame)
|
||||
if lenOfFrame > ringBufferElementSize {
|
||||
r.config.Logger.Log(smartlogger.Warning, pkg+"frame was too big", "frame size", lenOfFrame)
|
||||
|
@ -316,7 +314,6 @@ func (r *Revid) packClips() {
|
|||
packetCount++
|
||||
clipSize += lenOfFrame
|
||||
if packetCount >= r.config.FramesPerClip {
|
||||
fmt.Println("flushing buffer")
|
||||
r.ringBuffer.Flush()
|
||||
clipSize = 0
|
||||
packetCount = 0
|
||||
|
|
|
@ -29,7 +29,6 @@ LICENSE
|
|||
package revid
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -123,7 +122,6 @@ func (s *httpSender) load(c *ring.Chunk) error {
|
|||
|
||||
func (s *httpSender) send() error {
|
||||
if s.chunk == nil {
|
||||
fmt.Println("chunk is nil")
|
||||
// Do not retry with httpSender,
|
||||
// so just return without error
|
||||
// if the chunk has been cleared.
|
||||
|
@ -135,7 +133,6 @@ func (s *httpSender) send() error {
|
|||
pins := netsender.MakePins(ip, "V")
|
||||
for i, pin := range pins {
|
||||
if pin.Name == "V0" {
|
||||
fmt.Println("pin is V0")
|
||||
send = true
|
||||
pins[i].Value = s.chunk.Len()
|
||||
pins[i].Data = s.chunk.Bytes()
|
||||
|
@ -145,7 +142,6 @@ func (s *httpSender) send() error {
|
|||
}
|
||||
var err error
|
||||
if send {
|
||||
fmt.Println("sending")
|
||||
_, _, err = s.client.Send(netsender.RequestPoll, pins)
|
||||
}
|
||||
// We will not retry, so release
|
||||
|
|
Loading…
Reference in New Issue