From 95a9c3bbf1a12839d6a896c417b12d6071924d1f Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 18 Nov 2013 09:21:35 +0000 Subject: [PATCH] linuxdvb: old code would update tuning params even without auto-discovery This is important for correcting mistakes in the pre-defined configuration files, and also picking up potential changes (not sure that will quite work). The one thing that is left untouched is the frequency, a) to not confuse people and b) I've seen 2 transponders sending slightly diff freq and this can cause the config to be constantly updated. The one thing this will also do, for better or worse, is remove an AUTO settings. Cons are it could be less flexible an tuners may automatically deal with small changes in settings, Pro's are if you have some tuners that accept AUTO and some that don't, once its scanned on something that does it will get updated. Plus its probably better, where possible, to have the full settings. --- src/input/mpegts/linuxdvb/linuxdvb_network.c | 19 +++++++++++++++---- src/input/mpegts/linuxdvb/linuxdvb_private.h | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_network.c b/src/input/mpegts/linuxdvb/linuxdvb_network.c index 02c24d8e..178c7788 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_network.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_network.c @@ -213,7 +213,6 @@ static mpegts_mux_t * linuxdvb_network_find_mux ( linuxdvb_network_t *ln, dvb_mux_conf_t *dmc ) { -#define LINUXDVB_FREQ_TOL 2000 // TODO: fix this! mpegts_mux_t *mm; LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link) { linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; @@ -240,13 +239,25 @@ static mpegts_mux_t * linuxdvb_network_create_mux ( mpegts_mux_t *mm, uint16_t onid, uint16_t tsid, dvb_mux_conf_t *dmc ) { + int save = 0; linuxdvb_network_t *ln = (linuxdvb_network_t*)mm->mm_network; mm = linuxdvb_network_find_mux(ln, dmc); if (!mm && ln->mn_autodiscovery) { - mm = (mpegts_mux_t*)linuxdvb_mux_create0(ln, onid, tsid, dmc, NULL, NULL); - if (mm) - mm->mm_config_save(mm); + mm = (mpegts_mux_t*)linuxdvb_mux_create0(ln, onid, tsid, dmc, NULL, NULL); + save = 1; + } else if (mm) { + linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; + dmc->dmc_fe_params.frequency = lm->lm_tuning.dmc_fe_params.frequency; + // Note: keep original freq, else it can bounce around if diff transponders + // report it slightly differently. + // TODO: Note: should we also leave AUTO settings as is? + if (memcmp(&lm->lm_tuning, dmc, sizeof(lm->lm_tuning))) { + memcpy(&lm->lm_tuning, dmc, sizeof(lm->lm_tuning)); + save = 1; + } } + if (save) + mm->mm_config_save(mm); return mm; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 1e040396..5ae624ae 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -22,6 +22,9 @@ #include "input/mpegts.h" +/* Max allowed frequency variation for something to be considered the same */ +#define LINUXDVB_FREQ_TOL 2000 + typedef struct linuxdvb_hardware linuxdvb_hardware_t; typedef struct linuxdvb_device linuxdvb_device_t; typedef struct linuxdvb_adapter linuxdvb_adapter_t;