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 --- DOCS/man/en/options.rst | 23 +++++++++++------------ options/options.c | 4 ++-- options/options.h | 1 + player/loadfile.c | 4 ---- stream/dvbin.h | 2 +- stream/stream_dvb.c | 40 +++++++++++++++++++++------------------- 6 files changed, 36 insertions(+), 38 deletions(-) diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 981c1944e7..44219a35e9 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -735,18 +735,17 @@ OPTIONS This option is useful for debugging only. -``--dvbin=`` - Pass the following parameters to the DVB input module, in order to - override the default ones: - - :card=<1-4>: Specifies using card number 1-4 (default: 1). - :file=: Instructs mpv to read the channels list from - ````. Default is - ``~/.mpv/channels.conf.{sat,ter,cbl,atsc}`` (based - on your card type) or ``~/.mpv/channels.conf`` as a - last resort. - :timeout=<1-30>: Maximum number of seconds to wait when trying to tune a - frequency before giving up (default: 30). +``--dvbin-card=<1-4>`` + Specifies using card number 1-4 (default: 1). + +``--dvbin-file=`` + Instructs mpv to read the channels list from ````. Default is + ``~/.mpv/channels.conf.{sat,ter,cbl,atsc}`` (based on your card type) or + ``~/.mpv/channels.conf`` as a last resort. + +``--dvbin-timeout=<1-30>`` + Maximum number of seconds to wait when trying to tune a frequency before + giving up (default: 30). ``--dvd-device=`` Specify the DVD device or .iso filename (default: ``/dev/dvd``). You can diff --git a/options/options.c b/options/options.c index 509a408537..12057c6e9a 100644 --- a/options/options.c +++ b/options/options.c @@ -64,8 +64,8 @@ static void print_help(struct mp_log *log) extern const struct m_sub_options tv_params_conf; extern const struct m_sub_options stream_pvr_conf; extern const struct m_sub_options stream_cdda_conf; +extern const struct m_sub_options stream_dvb_conf; -extern const m_option_t dvbin_opts_conf[]; extern const m_option_t lavfdopts_conf[]; extern int sws_chr_vshift; @@ -248,7 +248,7 @@ const m_option_t mp_opts[] = { OPT_SUBSTRUCT("pvr", stream_pvr_opts, stream_pvr_conf, 0), #endif /* HAVE_PVR */ #if HAVE_DVBIN - {"dvbin", (void *) dvbin_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, + OPT_SUBSTRUCT("dvbin", stream_dvb_opts, stream_dvb_conf, 0), #endif // ------------------------- a-v sync options -------------------- diff --git a/options/options.h b/options/options.h index 09567db064..229361f767 100644 --- a/options/options.h +++ b/options/options.h @@ -241,6 +241,7 @@ typedef struct MPOpts { struct tv_params *tv_params; struct pvr_params *stream_pvr_opts; struct cdda_params *stream_cdda_opts; + struct dvb_params *stream_dvb_opts; char *cdrom_device; diff --git a/player/loadfile.c b/player/loadfile.c index 26f6c3a0c5..712ba58f02 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -59,10 +59,6 @@ #include "command.h" #include "libmpv/client.h" -#if HAVE_DVBIN -#include "stream/dvbin.h" -#endif - static void uninit_sub(struct MPContext *mpctx, int order) { if (mpctx->d_sub[order]) 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