summaryrefslogtreecommitdiffstats
path: root/stream/stream_cdda.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-02 17:02:34 +0200
committerwm4 <wm4@nowhere>2013-08-02 17:02:34 +0200
commitbc1d61cf4296ab41564adb896e454e48c292e451 (patch)
tree461dfa0cb61af73b62838608aa8fbb3dd99d3642 /stream/stream_cdda.c
parent964194b55bf86d7c8b76febe8bf54c49648e79c1 (diff)
downloadmpv-bc1d61cf4296ab41564adb896e454e48c292e451.tar.bz2
mpv-bc1d61cf4296ab41564adb896e454e48c292e451.tar.xz
stream: redo URL parsing, replace m_struct usage with m_config
Move the URL parsing code from m_option.c to stream.c, and simplify it dramatically. This code originates from times when http code used this, but now it's just relict from other stream implementations reusing this code. Remove the unused bits and simplify the rest. stream_vcd is insane, and the priv struct is different on every platform, so drop the URL parsing. This means you can't specify a track anymore, only the device. (Does anyone use stream_vcd? Not like this couldn't be fixed, but it doesn't seem worth the effort, especially because it'd require potentially touching platform specific code.)
Diffstat (limited to 'stream/stream_cdda.c')
-rw-r--r--stream/stream_cdda.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 1c8e2ca2d6..ff659b2d02 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -43,7 +43,6 @@
#include "stream.h"
#include "core/m_option.h"
-#include "core/m_struct.h"
#include "libavutil/common.h"
#include "compat/mpbswap.h"
@@ -60,9 +59,8 @@ typedef struct {
int start_sector;
int end_sector;
cd_info_t *cd_info;
-} cdda_priv;
-static struct cdda_params {
+ // options
int speed;
int paranoia_mode;
char *generic_dev;
@@ -73,23 +71,19 @@ static struct cdda_params {
int no_skip;
char *device;
int span[2];
-} cdda_dflts = {
+} cdda_priv;
+
+static cdda_priv cdda_dflts = {
.search_overlap = -1,
};
-#define ST_OFF(f) M_ST_OFF(struct cdda_params, f)
+#define OPT_BASE_STRUCT cdda_priv
static const m_option_t cdda_params_fields[] = {
- {"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},
+ OPT_INTPAIR("span", span, 0),
+ OPT_INTRANGE("speed", speed, 0, 1, 100),
+ OPT_STRING("device", device, 0),
{0}
};
-static const struct m_struct_st stream_opts = {
- "cdda",
- sizeof(struct cdda_params),
- &cdda_dflts,
- cdda_params_fields
-};
/// We keep these options but now they set the defaults
const m_option_t cdda_opts[] = {
@@ -319,20 +313,19 @@ static int control(stream_t *stream, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
-static int open_cdda(stream_t *st, int m, void *opts)
+static int open_cdda(stream_t *st, int m)
{
- struct cdda_params *p = (struct cdda_params *)opts;
+ cdda_priv *priv = st->priv;
+ cdda_priv *p = priv;
int mode = p->paranoia_mode;
int offset = p->toc_offset;
cdrom_drive_t *cdd = NULL;
- cdda_priv *priv;
cd_info_t *cd_info;
unsigned int audiolen = 0;
int last_track;
int i;
if (m != STREAM_READ) {
- m_struct_free(&stream_opts, opts);
return STREAM_UNSUPPORTED;
}
@@ -351,7 +344,6 @@ static int open_cdda(stream_t *st, int m, void *opts)
if (!cdd) {
mp_tmsg(MSGT_OPEN, MSGL_ERR, "Can't open CDDA device.\n");
- m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
@@ -363,7 +355,6 @@ static int open_cdda(stream_t *st, int m, void *opts)
if (cdda_open(cdd) != 0) {
mp_tmsg(MSGT_OPEN, MSGL_ERR, "Can't open disc.\n");
cdda_close(cdd);
- m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
@@ -424,7 +415,6 @@ static int open_cdda(stream_t *st, int m, void *opts)
cdda_close(cdd);
free(priv);
cd_info_free(cd_info);
- m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
@@ -465,8 +455,6 @@ static int open_cdda(stream_t *st, int m, void *opts)
st->demuxer = "rawaudio";
- m_struct_free(&stream_opts, opts);
-
print_cdtext(st, 0);
return STREAM_OK;
@@ -476,6 +464,13 @@ const stream_info_t stream_info_cdda = {
"cdda",
open_cdda,
{"cdda", NULL },
- &stream_opts,
- .opts_url = 1,
+ .priv_size = sizeof(cdda_priv),
+ .priv_defaults = &cdda_dflts,
+ .options = cdda_params_fields,
+ .url_options = {
+ {"hostname", "span"},
+ {"port", "speed"},
+ {"filename", "device"},
+ {0}
+ },
};