add HTTP retries for DLNA player
This commit is contained in:
+2
-2
@@ -153,16 +153,16 @@ func StartupApp(appName, displayAppName, appVersion, appVersionTag, latestReleas
|
||||
}
|
||||
|
||||
// Periodically scan for remote players
|
||||
go a.PlaybackManager.ScanRemotePlayers(a.bgrndCtx, 5 /*waitSec*/)
|
||||
go func() {
|
||||
t := time.NewTicker(5 * time.Minute)
|
||||
for {
|
||||
a.PlaybackManager.ScanRemotePlayers(a.bgrndCtx)
|
||||
select {
|
||||
case <-a.bgrndCtx.Done():
|
||||
t.Stop()
|
||||
return
|
||||
case <-t.C:
|
||||
continue
|
||||
a.PlaybackManager.ScanRemotePlayers(a.bgrndCtx, 10 /*waitSec*/)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -96,8 +96,8 @@ func (p *PlaybackManager) addOnTrackChangeHook() {
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PlaybackManager) ScanRemotePlayers(ctx context.Context) {
|
||||
devices, _ := device.SearchMediaRenderers(ctx, 10, services.AVTransport, services.RenderingControl)
|
||||
func (p *PlaybackManager) ScanRemotePlayers(ctx context.Context, waitSec int) {
|
||||
devices, _ := device.SearchMediaRenderers(ctx, waitSec, services.AVTransport, services.RenderingControl)
|
||||
|
||||
var discovered []remotePlayer
|
||||
for _, d := range devices {
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/backend/player"
|
||||
"github.com/dweymouth/supersonic/backend/util"
|
||||
"github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/supersonic-app/go-upnpcast/device"
|
||||
"github.com/supersonic-app/go-upnpcast/services/avtransport"
|
||||
"github.com/supersonic-app/go-upnpcast/services/renderingcontrol"
|
||||
@@ -62,14 +63,20 @@ type DLNAPlayer struct {
|
||||
}
|
||||
|
||||
func NewDLNAPlayer(device *device.MediaRenderer) (*DLNAPlayer, error) {
|
||||
retry := retryablehttp.NewClient()
|
||||
retry.RetryMax = 3
|
||||
cli := retry.StandardClient()
|
||||
|
||||
avt, err := device.AVTransportClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
avt.HTTPClient = cli
|
||||
rc, err := device.RenderingControlClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rc.HTTPClient = cli
|
||||
return &DLNAPlayer{
|
||||
avTransport: avt,
|
||||
renderControl: rc,
|
||||
|
||||
Reference in New Issue
Block a user