aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--common/playlist.c3
-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
-rw-r--r--player/loadfile.c20
8 files changed, 29 insertions, 25 deletions
diff --git a/common/playlist.c b/common/playlist.c
index 857f5cb030..70206b1cfe 100644
--- a/common/playlist.c
+++ b/common/playlist.c
@@ -278,7 +278,8 @@ struct playlist *playlist_parse_file(const char *file, struct mpv_global *global
return NULL;
}
- struct demuxer *pl_demux = demux_open(stream, "playlist", NULL, global);
+ struct demuxer_params p = {.force_format = "playlist"};
+ struct demuxer *pl_demux = demux_open(stream, &p, global);
if (pl_demux && pl_demux->playlist) {
ret = talloc_zero(NULL, struct playlist);
playlist_transfer_entries(ret, pl_demux->playlist);
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);
diff --git a/player/loadfile.c b/player/loadfile.c
index c6f0c137be..66f114b606 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -689,21 +689,20 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
goto err_out;
stream_enable_cache(&stream, &opts->stream_cache);
- char *demuxer_name = NULL;
+ struct demuxer_params params = {
+ .expect_subtitle = filter == STREAM_SUB,
+ };
+
switch (filter) {
case STREAM_SUB:
- demuxer_name = opts->sub_demuxer_name;
+ params.force_format = opts->sub_demuxer_name;
break;
case STREAM_AUDIO:
- demuxer_name = opts->audio_demuxer_name;
+ params.force_format = opts->audio_demuxer_name;
break;
}
- struct demuxer_params params = {
- .expect_subtitle = filter == STREAM_SUB,
- };
- struct demuxer *demuxer =
- demux_open(stream, demuxer_name, &params, mpctx->global);
+ struct demuxer *demuxer = demux_open(stream, &params, mpctx->global);
if (!demuxer) {
free_stream(stream);
goto err_out;
@@ -888,7 +887,7 @@ static void load_chapters(struct MPContext *mpctx)
struct stream *stream = stream_create(chapter_file, STREAM_READ,
mpctx->playback_abort, mpctx->global);
if (stream) {
- struct demuxer *demux = demux_open(stream, NULL, NULL, mpctx->global);
+ struct demuxer *demux = demux_open(stream, NULL, mpctx->global);
if (demux) {
src = demux;
free_src = true;
@@ -966,7 +965,8 @@ static void open_demux_thread(void *pctx)
struct demux_open_args *args = pctx;
struct stream *s = args->stream;
struct mpv_global *global = args->global;
- args->demux = demux_open(s, global->opts->demuxer_name, NULL, global);
+ struct demuxer_params p = {.force_format = global->opts->demuxer_name};
+ args->demux = demux_open(s, &p, global);
if (args->demux)
args->tl = timeline_load(global, args->log, args->demux);
}