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
|
// Periodically scan for remote players
|
||||||
|
go a.PlaybackManager.ScanRemotePlayers(a.bgrndCtx, 5 /*waitSec*/)
|
||||||
go func() {
|
go func() {
|
||||||
t := time.NewTicker(5 * time.Minute)
|
t := time.NewTicker(5 * time.Minute)
|
||||||
for {
|
for {
|
||||||
a.PlaybackManager.ScanRemotePlayers(a.bgrndCtx)
|
|
||||||
select {
|
select {
|
||||||
case <-a.bgrndCtx.Done():
|
case <-a.bgrndCtx.Done():
|
||||||
t.Stop()
|
t.Stop()
|
||||||
return
|
return
|
||||||
case <-t.C:
|
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) {
|
func (p *PlaybackManager) ScanRemotePlayers(ctx context.Context, waitSec int) {
|
||||||
devices, _ := device.SearchMediaRenderers(ctx, 10, services.AVTransport, services.RenderingControl)
|
devices, _ := device.SearchMediaRenderers(ctx, waitSec, services.AVTransport, services.RenderingControl)
|
||||||
|
|
||||||
var discovered []remotePlayer
|
var discovered []remotePlayer
|
||||||
for _, d := range devices {
|
for _, d := range devices {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||||
"github.com/dweymouth/supersonic/backend/player"
|
"github.com/dweymouth/supersonic/backend/player"
|
||||||
"github.com/dweymouth/supersonic/backend/util"
|
"github.com/dweymouth/supersonic/backend/util"
|
||||||
|
"github.com/hashicorp/go-retryablehttp"
|
||||||
"github.com/supersonic-app/go-upnpcast/device"
|
"github.com/supersonic-app/go-upnpcast/device"
|
||||||
"github.com/supersonic-app/go-upnpcast/services/avtransport"
|
"github.com/supersonic-app/go-upnpcast/services/avtransport"
|
||||||
"github.com/supersonic-app/go-upnpcast/services/renderingcontrol"
|
"github.com/supersonic-app/go-upnpcast/services/renderingcontrol"
|
||||||
@@ -62,14 +63,20 @@ type DLNAPlayer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewDLNAPlayer(device *device.MediaRenderer) (*DLNAPlayer, error) {
|
func NewDLNAPlayer(device *device.MediaRenderer) (*DLNAPlayer, error) {
|
||||||
|
retry := retryablehttp.NewClient()
|
||||||
|
retry.RetryMax = 3
|
||||||
|
cli := retry.StandardClient()
|
||||||
|
|
||||||
avt, err := device.AVTransportClient()
|
avt, err := device.AVTransportClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
avt.HTTPClient = cli
|
||||||
rc, err := device.RenderingControlClient()
|
rc, err := device.RenderingControlClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
rc.HTTPClient = cli
|
||||||
return &DLNAPlayer{
|
return &DLNAPlayer{
|
||||||
avTransport: avt,
|
avTransport: avt,
|
||||||
renderControl: rc,
|
renderControl: rc,
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ require (
|
|||||||
github.com/go-text/render v0.2.0 // indirect
|
github.com/go-text/render v0.2.0 // indirect
|
||||||
github.com/go-text/typesetting v0.2.1 // indirect
|
github.com/go-text/typesetting v0.2.1 // indirect
|
||||||
github.com/h2non/filetype v1.1.3 // indirect
|
github.com/h2non/filetype v1.1.3 // indirect
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
|
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
|
||||||
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08 // indirect
|
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08 // indirect
|
||||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
||||||
github.com/koron/go-ssdp v0.0.4 // indirect
|
github.com/koron/go-ssdp v0.0.4 // indirect
|
||||||
@@ -57,4 +59,5 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/supersonic-app/go-upnpcast v0.0.0-20250312000014-e4f7242a07ce => ../go-upnpcast
|
replace github.com/supersonic-app/go-upnpcast v0.0.0-20250312000014-e4f7242a07ce => ../go-upnpcast
|
||||||
|
|
||||||
replace fyne.io/fyne/v2 v2.6.0-beta1 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250308154116-c32a0de49bde
|
replace fyne.io/fyne/v2 v2.6.0-beta1 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250308154116-c32a0de49bde
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
|||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
|
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
|
||||||
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
|
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||||
|
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
|
||||||
|
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
|
||||||
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08 h1:wMeVzrPO3mfHIWLZtDcSaGAe2I4PW9B/P5nMkRSwCAc=
|
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08 h1:wMeVzrPO3mfHIWLZtDcSaGAe2I4PW9B/P5nMkRSwCAc=
|
||||||
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
|
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
|
||||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
|
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
|
||||||
|
|||||||
Reference in New Issue
Block a user