From 9cd4638d2bed50130e6ebdcf37405438cb16a29b Mon Sep 17 00:00:00 2001 From: Oliver Freyermuth Date: Tue, 1 Oct 2019 23:46:29 +0200 Subject: stream_dvb: Add dvb_update_config to poll config parameters. If any parameters have been updated, reinitiate streaming_start. Throttle checks since we poll from streaming_read. This also requires the player to re-initialize, since all video and audio streams and even the transport format may change. This is added in the next commit. --- stream/dvbin.h | 1 + stream/stream_dvb.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/stream/dvbin.h b/stream/dvbin.h index c184f189e7..60b4070f04 100644 --- a/stream/dvbin.h +++ b/stream/dvbin.h @@ -183,6 +183,7 @@ typedef struct { ) #endif +void dvb_update_config(stream_t *); int dvb_parse_path(stream_t *); int dvb_step_channel(stream_t *, int); int dvb_set_channel(stream_t *, unsigned int, unsigned int); diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index a6c98b91bc..5291ef9860 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -47,6 +47,7 @@ #include "osdep/io.h" #include "misc/ctype.h" +#include "osdep/timer.h" #include "stream.h" #include "common/tags.h" @@ -762,6 +763,9 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size) if (!pos) MP_ERR(stream, "dvb_streaming_read, return 0 bytes\n"); + // Check if config parameters have been updated. + dvb_update_config(stream); + return pos; } @@ -1054,6 +1058,34 @@ static int dvb_streaming_start(stream_t *stream, char *progname) return 1; } +void dvb_update_config(stream_t *stream) +{ + static int last_check = 0; + int now = (int)(mp_time_sec()*10); + + // Throttle the check to at maximum once every 0.1 s. + if (now != last_check) { + last_check = now; + dvb_priv_t *priv = (dvb_priv_t *) stream->priv; + if (m_config_cache_update(priv->opts_cache)) { + dvb_state_t *state = priv->state; + + // Re-parse stream path, if we have cfg parameters now, + // these should be preferred. + if (!dvb_parse_path(stream)) { + MP_ERR(stream, "error parsing DVB config, not tuning."); + return; + } + + int r = dvb_streaming_start(stream, priv->prog); + if (r) { + // Stream will be pulled down after channel switch, + // persist state. + state->switching_channel = true; + } + } + } +} static int dvb_open(stream_t *stream) { -- cgit v1.2.3