summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mpvcore/player/loadfile.c13
-rw-r--r--stream/stream.h1
-rw-r--r--stream/stream_rar.c12
3 files changed, 23 insertions, 3 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index 3f23b21234..00b6a4b97c 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -697,8 +697,15 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
mp_add_subtitles(mpctx, mpctx->opts->sub_name[i]);
}
if (mpctx->opts->sub_auto) { // auto load sub file ...
- struct subfn *list = find_text_subtitles(mpctx->opts, mpctx->filename);
- for (int i = 0; list[i].fname; i++) {
+ void *tmp = talloc_new(NULL);
+ char *base_filename = mpctx->filename;
+ char *stream_filename = NULL;
+ if (stream_control(mpctx->stream, STREAM_CTRL_GET_BASE_FILENAME,
+ &stream_filename) > 0)
+ base_filename = talloc_steal(tmp, stream_filename);
+ struct subfn *list = find_text_subtitles(mpctx->opts, base_filename);
+ talloc_steal(tmp, list);
+ for (int i = 0; list && list[i].fname; i++) {
char *filename = list[i].fname;
char *lang = list[i].lang;
for (int n = 0; n < mpctx->num_sources; n++) {
@@ -713,7 +720,7 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
}
skip:;
}
- talloc_free(list);
+ talloc_free(tmp);
}
}
diff --git a/stream/stream.h b/stream/stream.h
index e4864f81b1..6d43f02a7c 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -100,6 +100,7 @@ enum stream_ctrl {
STREAM_CTRL_GET_DVD_INFO,
STREAM_CTRL_SET_CONTENTS,
STREAM_CTRL_GET_METADATA,
+ STREAM_CTRL_GET_BASE_FILENAME,
};
struct stream_lang_req {
diff --git a/stream/stream_rar.c b/stream/stream_rar.c
index d3ccfa3bf3..8402517dc3 100644
--- a/stream/stream_rar.c
+++ b/stream/stream_rar.c
@@ -75,6 +75,17 @@ static void rar_entry_close(stream_t *s)
RarFileDelete(rar_file);
}
+static int rar_entry_control(stream_t *s, int cmd, void *arg)
+{
+ rar_file_t *rar_file = s->priv;
+ switch (cmd) {
+ case STREAM_CTRL_GET_BASE_FILENAME:
+ *(char **)arg = talloc_strdup(NULL, rar_file->s->url);
+ return STREAM_OK;
+ }
+ return STREAM_UNSUPPORTED;
+}
+
static int rar_entry_open(stream_t *stream, int mode)
{
if (!strchr(stream->path, '|'))
@@ -123,6 +134,7 @@ static int rar_entry_open(stream_t *stream, int mode)
stream->fill_buffer = rar_entry_fill_buffer;
stream->seek = rar_entry_seek;
stream->close = rar_entry_close;
+ stream->control = rar_entry_control;
return STREAM_OK;
}