diff options
author | Přemysl Janouch <p@janouch.name> | 2018-11-03 00:54:50 +0100 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-11-03 00:54:50 +0100 |
commit | 783fce1175f8ace7122b499c4f438e738cf11ee4 (patch) | |
tree | e39913b188a9a5d0a843c805c2b761d60f0a4b8d | |
parent | 23683424a62dc7f179592c74294b21d32e2670e7 (diff) | |
download | bbc-on-ice-783fce1175f8ace7122b499c4f438e738cf11ee4.tar.gz bbc-on-ice-783fce1175f8ace7122b499c4f438e738cf11ee4.tar.xz bbc-on-ice-783fce1175f8ace7122b499c4f438e738cf11ee4.zip |
Fix metadata timeouts
-rw-r--r-- | main.go | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -122,21 +122,22 @@ func resolveM3U8(target string) (out []string, err error) { func metaProc(ctx context.Context, name string, out chan<- string) { defer close(out) + // "polling_timeout" seems to normally be 25 seconds, which is a lot, + // especially considering all the possible additional buffering. + const maxInterval = 5 * time.Second + var current, last string var interval time.Duration for { meta, err := getMeta(name) if err != nil { current = name + " - " + err.Error() - interval = 30 * time.Second + interval = maxInterval } else { current = meta.title - interval = time.Duration(meta.timeout) - - // It seems to normally use 25 seconds which is a lot, - // especially considering all the possible additional buffering. - if interval > 5000 { - interval = 5000 + interval = time.Duration(meta.timeout) * time.Millisecond + if interval > maxInterval { + interval = maxInterval } } if current != last { @@ -149,7 +150,7 @@ func metaProc(ctx context.Context, name string, out chan<- string) { } select { - case <-time.After(time.Duration(interval) * time.Millisecond): + case <-time.After(interval): case <-ctx.Done(): return } |