summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-24 15:40:01 +0200
committerwm4 <wm4@nowhere>2014-10-24 15:40:01 +0200
commit07cca2500ef92f1972fcbc1b89a8d4bd3e3c7696 (patch)
tree3acd2a5da0df625929a1bedf4e04a9cd66a00e97
parentf1481df0b63c27f1417cddf8fb0c1bf12ff58b82 (diff)
downloadmpv-07cca2500ef92f1972fcbc1b89a8d4bd3e3c7696.tar.bz2
mpv-07cca2500ef92f1972fcbc1b89a8d4bd3e3c7696.tar.xz
demux: cache STREAM_CTRL_GET_BASE_FILENAME
It's needed for some obscure feature in combination with .rar reading. However, it's unconditionally used by the subtitle loader code, so take care of not blocking the main thread unnecessarily. (Untested.)
-rw-r--r--demux/demux.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 7c563e9625..0bfb150cfd 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -129,6 +129,8 @@ struct demux_internal {
int64_t stream_cache_size;
int64_t stream_cache_fill;
int stream_cache_idle;
+ // Updated during init only.
+ char *stream_base_filename;
};
struct demux_stream {
@@ -786,6 +788,16 @@ void demux_update(demuxer_t *demuxer)
pthread_mutex_unlock(&in->lock);
}
+static void demux_init_cache(struct demuxer *demuxer)
+{
+ struct demux_internal *in = demuxer->in;
+ struct stream *stream = demuxer->stream;
+
+ char *base = NULL;
+ stream_control(stream, STREAM_CTRL_GET_BASE_FILENAME, &base);
+ in->stream_base_filename = talloc_steal(demuxer, base);
+}
+
static struct demuxer *open_given_type(struct mpv_global *global,
struct mp_log *log,
const struct demuxer_desc *desc,
@@ -855,6 +867,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
mp_warn(log, "Enabling seeking because stream cache is active.\n");
in->d_thread->seekable = true;
}
+ demux_init_cache(demuxer);
demux_changed(in->d_thread, DEMUX_EVENT_ALL);
demux_update(demuxer);
return demuxer;
@@ -1146,6 +1159,11 @@ static int cached_stream_control(struct demux_internal *in, int cmd, void *arg)
return STREAM_UNSUPPORTED;
*(int64_t *)arg = in->stream_size;
return STREAM_OK;
+ case STREAM_CTRL_GET_BASE_FILENAME:
+ if (!in->stream_base_filename)
+ return STREAM_UNSUPPORTED;
+ *(char **)arg = talloc_strdup(NULL, in->stream_base_filename);
+ return STREAM_OK;
}
return STREAM_ERROR;
}