summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Freyermuth <o.freyermuth@googlemail.com>2019-10-01 23:46:29 +0200
committerOliver Freyermuth <o.freyermuth@googlemail.com>2019-10-02 01:25:45 +0200
commit9cd4638d2bed50130e6ebdcf37405438cb16a29b (patch)
tree9af6342d09bdb2f8529ad473a5ac01f5d72aecdf
parent1768ea0d1576136130cb5f2b7f459704031bafd2 (diff)
downloadmpv-9cd4638d2bed50130e6ebdcf37405438cb16a29b.tar.bz2
mpv-9cd4638d2bed50130e6ebdcf37405438cb16a29b.tar.xz
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.
-rw-r--r--stream/dvbin.h1
-rw-r--r--stream/stream_dvb.c32
2 files changed, 33 insertions, 0 deletions
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)
{