summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-10 20:46:15 +0200
committerwm4 <wm4@nowhere>2014-06-11 00:34:46 +0200
commit77a7aa2c41d4d4be2eb2ad099b201d3fdd8f3cc7 (patch)
treed72e8ec7a75a2e6c60060740629062f7bad895c7
parent7689f5f7cedcafe30d8ede3609cf4f2a3314a1d8 (diff)
downloadmpv-77a7aa2c41d4d4be2eb2ad099b201d3fdd8f3cc7.tar.bz2
mpv-77a7aa2c41d4d4be2eb2ad099b201d3fdd8f3cc7.tar.xz
stream_cdda: remove global option variables
-rw-r--r--DOCS/man/en/options.rst51
-rw-r--r--options/options.c6
-rw-r--r--options/options.h3
-rw-r--r--stream/stream.c1
-rw-r--r--stream/stream.h2
-rw-r--r--stream/stream_cdda.c67
6 files changed, 66 insertions, 64 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index e534b1aeb1..981c1944e7 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -427,42 +427,37 @@ OPTIONS
on the situation, either of these might be slower than the other method.
This option allows control over this.
-``--cdda=<option1:option2>``
- This option can be used to tune the CD Audio reading feature of mpv.
+``--cdda-...``
+ These options can be used to tune the CD Audio reading feature of mpv.
- Available options are:
-
- ``speed=<value>``
- Set CD spin speed.
-
- ``paranoia=<0-2>``
- Set paranoia level. Values other than 0 seem to break playback of
- anything but the first track.
+``--cdda-speed=<value>``
+ Set CD spin speed.
- :0: disable checking (default)
- :1: overlap checking only
- :2: full data correction and verification
+``--cdda-paranoia=<0-2>``
+ Set paranoia level. Values other than 0 seem to break playback of
+ anything but the first track.
- ``generic-dev=<value>``
- Use specified generic SCSI device.
+ :0: disable checking (default)
+ :1: overlap checking only
+ :2: full data correction and verification
- ``sector-size=<value>``
- Set atomic read size.
+``--cdda-sector-size=<value>``
+ Set atomic read size.
- ``overlap=<value>``
- Force minimum overlap search during verification to <value> sectors.
+``--cdda-overlap=<value>``
+ Force minimum overlap search during verification to <value> sectors.
- ``toc-bias``
- Assume that the beginning offset of track 1 as reported in the TOC
- will be addressed as LBA 0. Some discs need this for getting track
- boundaries correctly.
+``--cdda-toc-bias``
+ Assume that the beginning offset of track 1 as reported in the TOC
+ will be addressed as LBA 0. Some discs need this for getting track
+ boundaries correctly.
- ``toc-offset=<value>``
- Add ``<value>`` sectors to the values reported when addressing tracks.
- May be negative.
+``--cdda-toc-offset=<value>``
+ Add ``<value>`` sectors to the values reported when addressing tracks.
+ May be negative.
- ``(no-)skip``
- (Never) accept imperfect data reconstruction.
+``--cdda-skip=<es|no``
+ (Never) accept imperfect data reconstruction.
``--cdrom-device=<path>``
Specify the CD-ROM device (default: ``/dev/cdrom``).
diff --git a/options/options.c b/options/options.c
index 466049a91c..509a408537 100644
--- a/options/options.c
+++ b/options/options.c
@@ -46,7 +46,6 @@
/* defined in demux: */
extern const m_option_t demux_rawaudio_opts[];
extern const m_option_t demux_rawvideo_opts[];
-extern const m_option_t cdda_opts[];
extern int sws_flags;
@@ -64,6 +63,7 @@ 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 m_option_t dvbin_opts_conf[];
extern const m_option_t lavfdopts_conf[];
@@ -170,7 +170,6 @@ const m_option_t mp_opts[] = {
({"no", 0})),
OPT_INTRANGE("cache-pause-restart", stream_cache_unpause, 0, 0, 0x7fffffff),
- {"cdrom-device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
#if HAVE_DVDREAD || HAVE_DVDNAV
{"dvd-device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"dvd-speed", &dvd_speed, CONF_TYPE_INT, 0, 0, 0, NULL},
@@ -231,7 +230,8 @@ const m_option_t mp_opts[] = {
OPT_FLAG("quvi-fetch-subtitles", quvi_fetch_subtitles, 0),
#if HAVE_CDDA
- { "cdda", (void *)&cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ OPT_SUBSTRUCT("cdda", stream_cdda_opts, stream_cdda_conf, 0),
+ OPT_STRING("cdrom-device", cdrom_device, 0),
#endif
// demuxer.c - select audio/sub file/demuxer
diff --git a/options/options.h b/options/options.h
index ec572fe1d1..09567db064 100644
--- a/options/options.h
+++ b/options/options.h
@@ -240,6 +240,9 @@ typedef struct MPOpts {
struct tv_params *tv_params;
struct pvr_params *stream_pvr_opts;
+ struct cdda_params *stream_cdda_opts;
+
+ char *cdrom_device;
struct lavc_param {
int fast;
diff --git a/stream/stream.c b/stream/stream.c
index 617420b5ae..8542515567 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -53,7 +53,6 @@
#define TOTAL_BUFFER_SIZE (STREAM_MAX_BUFFER_SIZE + STREAM_MAX_SECTOR_SIZE)
/// We keep these 2 for the gui atm, but they will be removed.
-char *cdrom_device = NULL;
char *dvd_device = NULL;
int dvd_title = 0;
diff --git a/stream/stream.h b/stream/stream.h
index 4561ec3cdc..cb6c60c197 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -249,7 +249,7 @@ bool stream_manages_timeline(stream_t *s);
extern int dvd_title;
extern int dvd_angle;
extern int dvd_speed;
-extern char *dvd_device, *cdrom_device;
+extern char *dvd_device;
extern int bluray_angle;
extern char *bluray_device;
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 976b809299..b11671333a 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -43,11 +43,13 @@
#include "stream.h"
#include "options/m_option.h"
+#include "options/m_config.h"
+#include "options/options.h"
#include "compat/mpbswap.h"
#include "common/msg.h"
-typedef struct {
+typedef struct cdda_params {
cdrom_drive_t *cd;
cdrom_paranoia_t *cdp;
int sector;
@@ -57,21 +59,17 @@ typedef struct {
// options
int speed;
int paranoia_mode;
- char *generic_dev;
int sector_size;
int search_overlap;
int toc_bias;
int toc_offset;
- int no_skip;
+ int skip;
char *device;
int span[2];
} cdda_priv;
-static cdda_priv cdda_dflts = {
- .search_overlap = -1,
-};
+#define OPT_BASE_STRUCT struct cdda_params
-#define OPT_BASE_STRUCT cdda_priv
static const m_option_t cdda_params_fields[] = {
OPT_INTPAIR("span", span, 0),
OPT_INTRANGE("speed", speed, 0, 1, 100),
@@ -79,23 +77,24 @@ static const m_option_t cdda_params_fields[] = {
{0}
};
-/// We keep these options but now they set the defaults
-const m_option_t cdda_opts[] = {
- {"speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL},
- {"paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT, M_OPT_RANGE, 0, 2,
- NULL},
- {"generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE, 1,
- 100, NULL},
- {"overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE, 0, 75,
- NULL},
- {"toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL},
- {"toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL},
- {"noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0, 1, 0, NULL},
- {"device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"span", &cdda_dflts.span, CONF_TYPE_INT_PAIR, 0, 0, 0, NULL},
- {NULL, NULL, 0, 0, 0, 0, NULL}
+const struct m_sub_options stream_cdda_conf = {
+ .opts = (const m_option_t[]) {
+ OPT_INTRANGE("speed", speed, 0, 1, 100),
+ OPT_INTRANGE("paranoia", paranoia_mode, 0, 0, 2),
+ OPT_INTRANGE("sector-size", sector_size, 0, 1, 100),
+ OPT_INTRANGE("overlap", search_overlap, 0, 0, 75),
+ OPT_INT("toc-bias", toc_bias, 0),
+ OPT_INT("toc-offset", toc_offset, 0),
+ OPT_FLAG("skip", skip, 0),
+ OPT_STRING("device", device, 0),
+ OPT_INTPAIR("span", span, 0),
+ {0}
+ },
+ .size = sizeof(struct cdda_params),
+ .defaults = &(const struct cdda_params){
+ .search_overlap = -1,
+ .skip = 1,
+ },
};
static const char *cdtext_name[] = {
@@ -292,9 +291,10 @@ static int open_cdda(stream_t *st)
cdrom_drive_t *cdd = NULL;
int last_track;
- if (!p->device) {
- if (cdrom_device)
- p->device = talloc_strdup(NULL, cdrom_device);
+ if (!p->device || !p->device[0]) {
+ talloc_free(p->device);
+ if (st->opts->cdrom_device && st->opts->cdrom_device[0])
+ p->device = talloc_strdup(NULL, st->opts->cdrom_device);
else
p->device = talloc_strdup(NULL, DEFAULT_CDROM_DEVICE);
}
@@ -367,10 +367,10 @@ static int open_cdda(stream_t *st)
else
mode = PARANOIA_MODE_FULL;
- if (p->no_skip)
- mode |= PARANOIA_MODE_NEVERSKIP;
- else
+ if (p->skip)
mode &= ~PARANOIA_MODE_NEVERSKIP;
+ else
+ mode |= PARANOIA_MODE_NEVERSKIP;
if (p->search_overlap > 0)
mode |= PARANOIA_MODE_OVERLAP;
@@ -403,12 +403,17 @@ static int open_cdda(stream_t *st)
return STREAM_OK;
}
+static void *get_defaults(stream_t *st)
+{
+ return m_sub_options_copy(st, &stream_cdda_conf, st->opts->stream_cdda_opts);
+}
+
const stream_info_t stream_info_cdda = {
.name = "cdda",
.open = open_cdda,
.protocols = (const char*[]){"cdda", NULL },
.priv_size = sizeof(cdda_priv),
- .priv_defaults = &cdda_dflts,
+ .get_defaults = get_defaults,
.options = cdda_params_fields,
.url_options = (const char*[]){
"hostname=span",