summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-20 21:21:14 +0100
committerwm4 <wm4@nowhere>2015-02-20 21:21:14 +0100
commit6aa6778ac46672dd237acc86856353d133917f06 (patch)
treed7e19e4c35ea99193b826fcd78e975c1bc376f62 /demux
parent6c1355be967751b194504ed73b053846fbae5fa9 (diff)
downloadmpv-6aa6778ac46672dd237acc86856353d133917f06.tar.bz2
mpv-6aa6778ac46672dd237acc86856353d133917f06.tar.xz
demux: change demux_open() signature
Fold the relatively obscure force_format parameter into demuxer_params.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c8
-rw-r--r--demux/demux.h4
-rw-r--r--demux/demux_cue.c5
-rw-r--r--demux/demux_disc.c7
-rw-r--r--demux/demux_edl.c2
-rw-r--r--demux/demux_mkv_timeline.c5
6 files changed, 17 insertions, 14 deletions
diff --git a/demux/demux.c b/demux/demux.c
index b10b0d6f45..a08f633289 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -951,8 +951,6 @@ static struct demuxer *open_given_type(struct mpv_global *global,
mp_verbose(log, "Trying demuxer: %s (force-level: %s)\n",
desc->name, d_level(check));
- in->d_thread->params = params; // temporary during open()
-
if (stream->seekable) // not for DVD/BD/DVB in particular
stream_seek(stream, 0);
@@ -960,6 +958,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
// or stream filters will flush previous peeked data.
stream_peek(stream, STREAM_BUFFER_SIZE);
+ in->d_thread->params = params; // temporary during open()
int ret = demuxer->desc->open(in->d_thread, check);
if (ret >= 0) {
in->d_thread->params = NULL;
@@ -990,14 +989,15 @@ static const int d_normal[] = {DEMUX_CHECK_NORMAL, DEMUX_CHECK_UNSAFE, -1};
static const int d_request[] = {DEMUX_CHECK_REQUEST, -1};
static const int d_force[] = {DEMUX_CHECK_FORCE, -1};
-struct demuxer *demux_open(struct stream *stream, char *force_format,
- struct demuxer_params *params,
+// params can be NULL
+struct demuxer *demux_open(struct stream *stream, struct demuxer_params *params,
struct mpv_global *global)
{
const int *check_levels = d_normal;
const struct demuxer_desc *check_desc = NULL;
struct mp_log *log = mp_log_new(NULL, global->log, "!demux");
struct demuxer *demuxer = NULL;
+ char *force_format = params ? params->force_format : NULL;
if (!force_format)
force_format = stream->demuxer;
diff --git a/demux/demux.h b/demux/demux.h
index 848c7701f0..b76fb8fedc 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -166,6 +166,7 @@ typedef struct demux_attachment
} demux_attachment_t;
struct demuxer_params {
+ char *force_format;
int matroska_num_wanted_uids;
struct matroska_segment_uid *matroska_wanted_uids;
int matroska_wanted_segment;
@@ -255,8 +256,7 @@ struct demux_packet *demux_read_any_packet(struct demuxer *demuxer);
struct sh_stream *new_sh_stream(struct demuxer *demuxer, enum stream_type type);
-struct demuxer *demux_open(struct stream *stream, char *force_format,
- struct demuxer_params *params,
+struct demuxer *demux_open(struct stream *stream, struct demuxer_params *params,
struct mpv_global *global);
void demux_start_thread(struct demuxer *demuxer);
diff --git a/demux/demux_cue.c b/demux/demux_cue.c
index db70586b16..93c842dc0d 100644
--- a/demux/demux_cue.c
+++ b/demux/demux_cue.c
@@ -195,7 +195,7 @@ static bool try_open(struct timeline *tl, char *filename)
struct stream *s = stream_open(filename, tl->global);
if (!s)
return false;
- struct demuxer *d = demux_open(s, NULL, NULL, tl->global);
+ struct demuxer *d = demux_open(s, NULL, tl->global);
// Since .bin files are raw PCM data with no headers, we have to explicitly
// open them. Also, try to avoid to open files that are most likely not .bin
// files, as that would only play noise. Checking the file extension is
@@ -204,7 +204,8 @@ static bool try_open(struct timeline *tl, char *filename)
// CD sector size (2352 bytes)
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
MP_WARN(tl, "CUE: Opening as BIN file!\n");
- d = demux_open(s, "rawaudio", NULL, tl->global);
+ struct demuxer_params p = {.force_format = "rawaudio"};
+ d = demux_open(s, &p, tl->global);
}
if (d) {
add_source(tl, d);
diff --git a/demux/demux_disc.c b/demux/demux_disc.c
index afa8de2298..3cbd01a9b8 100644
--- a/demux/demux_disc.c
+++ b/demux/demux_disc.c
@@ -293,9 +293,10 @@ static int d_open(demuxer_t *demuxer, enum demux_check check)
if (check != DEMUX_CHECK_FORCE)
return -1;
- char *demux = "+lavf";
+ struct demuxer_params params = {.force_format = "+lavf"};
+
if (demuxer->stream->uncached_type == STREAMTYPE_CDDA)
- demux = "+rawaudio";
+ params.force_format = "+rawaudio";
char *t = NULL;
stream_control(demuxer->stream, STREAM_CTRL_GET_DISC_NAME, &t);
@@ -309,7 +310,7 @@ static int d_open(demuxer_t *demuxer, enum demux_check check)
stream_peek(demuxer->stream, 1);
reset_pts(demuxer);
- p->slave = demux_open(demuxer->stream, demux, NULL, demuxer->global);
+ p->slave = demux_open(demuxer->stream, &params, demuxer->global);
if (!p->slave)
return -1;
diff --git a/demux/demux_edl.c b/demux/demux_edl.c
index f12ca2c8a1..ba88e6a3d5 100644
--- a/demux/demux_edl.c
+++ b/demux/demux_edl.c
@@ -141,7 +141,7 @@ static struct demuxer *open_file(char *filename, struct timeline *tl)
struct stream *s = stream_open(filename, tl->global);
if (s) {
stream_enable_cache(&s, &opts->stream_cache);
- d = demux_open(s, NULL, NULL, tl->global);
+ d = demux_open(s, NULL, tl->global);
}
if (!d) {
MP_ERR(tl, "EDL: Could not open source file '%s'.\n", filename);
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index 735678f7db..64d4583979 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -167,7 +167,7 @@ static int enable_cache(struct mpv_global *global, struct stream **stream,
stream_enable_cache(stream, &opts->stream_cache);
- *demuxer = demux_open(*stream, "mkv", params, global);
+ *demuxer = demux_open(*stream, params, global);
if (!*demuxer) {
talloc_free(filename);
free_stream(*stream);
@@ -197,6 +197,7 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources,
{
bool was_valid = false;
struct demuxer_params params = {
+ .force_format = "mkv",
.matroska_num_wanted_uids = *num_sources,
.matroska_wanted_uids = *uids,
.matroska_wanted_segment = segment,
@@ -205,7 +206,7 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources,
struct stream *s = stream_open(filename, ctx->global);
if (!s)
return false;
- struct demuxer *d = demux_open(s, "mkv", &params, ctx->global);
+ struct demuxer *d = demux_open(s, &params, ctx->global);
if (!d) {
free_stream(s);