summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/m_option.c56
-rw-r--r--core/m_option.h17
-rw-r--r--stream/stream_cdda.c31
3 files changed, 15 insertions, 89 deletions
diff --git a/core/m_option.c b/core/m_option.c
index 20391a5846..2feaa5a4b1 100644
--- a/core/m_option.c
+++ b/core/m_option.c
@@ -1863,62 +1863,6 @@ static int get_obj_params(struct bstr opt_name, struct bstr name,
return 1;
}
-static int parse_obj_params(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
-{
- char **opts;
- int r;
- m_obj_params_t *p = opt->priv;
- const m_struct_t *desc;
-
- // We need the object desc
- if (!p)
- return M_OPT_INVALID;
-
- desc = p->desc;
- r = get_obj_params(name, bstr0(desc->name), param, desc, p->separator,
- dst ? &opts : NULL);
- if (r < 0)
- return r;
- if (!dst)
- return 1;
- if (!opts) // no arguments given
- return 1;
-
- for (r = 0; opts[r]; r += 2)
- m_struct_set(desc, dst, opts[r], bstr0(opts[r + 1]));
-
- return 1;
-}
-
-
-const m_option_type_t m_option_type_obj_params = {
- .name = "Object params",
- .parse = parse_obj_params,
-};
-
-/// Some predefined types as a definition would be quite lengthy
-
-/// Span arguments
-static const m_span_t m_span_params_dflts = {
- -1, -1
-};
-static const m_option_t m_span_params_fields[] = {
- {"start", M_ST_OFF(m_span_t, start), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL},
- {"end", M_ST_OFF(m_span_t, end), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL},
- { NULL, NULL, 0, 0, 0, 0, NULL }
-};
-static const struct m_struct_st m_span_opts = {
- "m_span",
- sizeof(m_span_t),
- &m_span_params_dflts,
- m_span_params_fields
-};
-const m_obj_params_t m_span_params_def = {
- &m_span_opts,
- '-'
-};
-
static int parse_obj_settings(struct bstr opt, struct bstr str,
const m_obj_list_t *list,
m_obj_settings_t **_ret, int ret_n)
diff --git a/core/m_option.h b/core/m_option.h
index fd0ebbd44c..dd1dbd3d75 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -133,20 +133,6 @@ typedef struct {
char separator;
} m_obj_params_t;
-// Parse a set of parameters.
-/** Parameters are separated by the given separator and each one
- * successively sets a field from the struct. The option priv field
- * (\ref m_option::priv) must point to a \ref m_obj_params_t.
- */
-extern const m_option_type_t m_option_type_obj_params;
-
-typedef struct {
- int start;
- int end;
-} m_span_t;
-// Ready made settings to parse a \ref m_span_t with a start-end syntax.
-extern const m_obj_params_t m_span_params_def;
-
struct m_opt_choice_alternatives {
char *name;
int value;
@@ -178,12 +164,12 @@ struct m_sub_options {
#define CONF_TYPE_IMGFMT (&m_option_type_imgfmt)
#define CONF_TYPE_FOURCC (&m_option_type_fourcc)
#define CONF_TYPE_AFMT (&m_option_type_afmt)
-#define CONF_TYPE_SPAN (&m_option_type_span)
#define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list)
#define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url)
#define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params)
#define CONF_TYPE_TIME (&m_option_type_time)
#define CONF_TYPE_CHOICE (&m_option_type_choice)
+#define CONF_TYPE_INT_PAIR (&m_option_type_intpair)
// Possible option values. Code is allowed to access option data without going
// through this union. It serves for self-documentation and to get minimal
@@ -202,7 +188,6 @@ union m_option_value {
int imgfmt;
unsigned int fourcc;
int afmt;
- m_span_t span;
m_obj_settings_t *obj_settings_list;
double time;
struct m_rel_time rel_time;
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 2541e70174..6fbd18fcc2 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -71,7 +71,7 @@ static struct cdda_params {
int toc_offset;
int no_skip;
char *device;
- m_span_t span;
+ int span[2];
} cdda_dflts = {
.search_overlap = -1,
};
@@ -91,11 +91,9 @@ static const m_option_t cdda_params_fields[] = {
{"noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0,
- (void *)&m_span_params_def},
+ {"span", ST_OFF(span), CONF_TYPE_INT_PAIR, 0, 0, 0, NULL},
/// For url parsing
- {"hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0,
- (void *)&m_span_params_def},
+ {"hostname", ST_OFF(span), CONF_TYPE_INT_PAIR, 0, 0, 0, NULL},
{"port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL},
{"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL},
{0}
@@ -122,8 +120,7 @@ const m_option_t cdda_opts[] = {
{"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_OBJ_PARAMS, 0, 0, 0,
- (void *)&m_span_params_def},
+ {"span", &cdda_dflts.span, CONF_TYPE_INT_PAIR, 0, 0, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
@@ -435,19 +432,19 @@ static int open_cdda(stream_t *st, int m, void *opts, int *file_format)
cdda_speed_set(cdd, p->speed);
last_track = cdda_tracks(cdd);
- if (p->span.start > last_track)
- p->span.start = last_track;
- if (p->span.end < p->span.start)
- p->span.end = p->span.start;
- if (p->span.end > last_track)
- p->span.end = last_track;
- if (p->span.start)
- priv->start_sector = cdda_track_firstsector(cdd, p->span.start);
+ if (p->span[0] > last_track)
+ p->span[0] = last_track;
+ if (p->span[1] < p->span[0])
+ p->span[1] = p->span[0];
+ if (p->span[1] > last_track)
+ p->span[1] = last_track;
+ if (p->span[0])
+ priv->start_sector = cdda_track_firstsector(cdd, p->span[0]);
else
priv->start_sector = cdda_disc_firstsector(cdd);
- if (p->span.end)
- priv->end_sector = cdda_track_lastsector(cdd, p->span.end);
+ if (p->span[1])
+ priv->end_sector = cdda_track_lastsector(cdd, p->span[1]);
else
priv->end_sector = cdda_disc_lastsector(cdd);