Supervisor tweaks (#1017)
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
publishWaitDuration = 10 * time.Second
|
||||
publishWaitDuration = 30 * time.Second
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -37,6 +37,8 @@ type PublicationMonitor struct {
|
||||
publishedTrack types.LocalMediaTrack
|
||||
isMuted bool
|
||||
unmutedAt time.Time
|
||||
|
||||
lastError error
|
||||
}
|
||||
|
||||
func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor {
|
||||
@@ -108,6 +110,12 @@ func (p *PublicationMonitor) clearPublishedTrack(pubTrack types.LocalMediaTrack)
|
||||
|
||||
func (p *PublicationMonitor) Check() error {
|
||||
p.lock.RLock()
|
||||
if p.lastError != nil {
|
||||
p.lock.RUnlock()
|
||||
// return an error only once
|
||||
return nil
|
||||
}
|
||||
|
||||
var pub *publish
|
||||
if p.desiredPublishes.Len() > 0 {
|
||||
pub = p.desiredPublishes.Front().(*publish)
|
||||
@@ -123,6 +131,10 @@ func (p *PublicationMonitor) Check() error {
|
||||
|
||||
if pub.isStart && !isMuted && !unmutedAt.IsZero() && time.Since(unmutedAt) > publishWaitDuration {
|
||||
// timed out waiting for publish
|
||||
p.lock.Lock()
|
||||
p.lastError = errPublishTimeout
|
||||
p.lock.Unlock()
|
||||
|
||||
return errPublishTimeout
|
||||
}
|
||||
|
||||
@@ -154,5 +166,7 @@ func (p *PublicationMonitor) update() {
|
||||
p.desiredPublishes.PushFront(pub)
|
||||
return
|
||||
}
|
||||
|
||||
p.lastError = nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user