stream_cdda: remove global option variables

This commit is contained in:
wm4
2014-06-10 20:46:15 +02:00
parent 7689f5f7ce
commit 77a7aa2c41
6 changed files with 66 additions and 64 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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",