From 959b718957527710b4bcf6e7227a0beaeb034137 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jun 2014 21:44:50 +0200 Subject: stream_dvb: remove global option variables --- stream/dvbin.h | 2 +- stream/stream_dvb.c | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) (limited to 'stream') diff --git a/stream/dvbin.h b/stream/dvbin.h index 4caba45c7d..1eb7174af0 100644 --- a/stream/dvbin.h +++ b/stream/dvbin.h @@ -75,7 +75,7 @@ typedef struct { void *priv; } dvb_config_t; -typedef struct { +typedef struct dvb_params { struct mp_log *log; int fd; int card; diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index c1697ddebd..e71a41e960 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -47,7 +47,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "osdep/io.h" #include "stream.h" +#include "options/m_config.h" #include "options/m_option.h" +#include "options/options.h" #include "options/path.h" #include "dvbin.h" @@ -61,14 +63,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //TODO: CAMBIARE list_ptr e da globale a per_priv - -static dvb_priv_t stream_defaults = { - .cfg_prog = "", - .cfg_card = 1, - .cfg_timeout = 30, -}; - -#define OPT_BASE_STRUCT dvb_priv_t +#define OPT_BASE_STRUCT struct dvb_params /// URL definition static const m_option_t stream_params[] = { @@ -77,17 +72,21 @@ static const m_option_t stream_params[] = { {0} }; -const m_option_t dvbin_opts_conf[] = { - {"prog", &stream_defaults.cfg_prog, CONF_TYPE_STRING, 0, 0 ,0, NULL}, - {"card", &stream_defaults.cfg_card, CONF_TYPE_INT, M_OPT_RANGE, 1, 4, NULL}, - {"timeout", &stream_defaults.cfg_timeout, CONF_TYPE_INT, M_OPT_RANGE, 1, 30, NULL}, - - {NULL, NULL, 0, 0, 0, 0, NULL} +const struct m_sub_options stream_dvb_conf = { + .opts = (const m_option_t[]) { + OPT_STRING("prog", cfg_prog, 0), + OPT_INTRANGE("card", cfg_card, 0, 1, 4), + OPT_INTRANGE("timeout", cfg_timeout, 0, 1, 30), + {0} + }, + .size = sizeof(struct dvb_params), + .defaults = &(const struct dvb_params){ + .cfg_prog = "", + .cfg_card = 1, + .cfg_timeout = 30, + }, }; - - - static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, int type) { dvb_channels_list *list; @@ -816,14 +815,17 @@ dvb_config_t *dvb_get_config(stream_t *stream) return conf; } - +static void *get_defaults(stream_t *st) +{ + return m_sub_options_copy(st, &stream_dvb_conf, st->opts->stream_dvb_opts); +} const stream_info_t stream_info_dvb = { .name = "dvbin", .open = dvb_open, .protocols = (const char*[]){ "dvb", NULL }, .priv_size = sizeof(dvb_priv_t), - .priv_defaults = &stream_defaults, + .get_defaults = get_defaults, .options = stream_params, .url_options = (const char*[]){ "hostname=prog", -- cgit v1.2.3