summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-14 22:02:52 +0100
committerwm4 <wm4@nowhere>2014-01-15 20:57:09 +0100
commit1bc1cd2305c65521010a3fa221ac785ac30b8d2d (patch)
treed4dceef8061d972649a606c7858614b6a57edd3c
parenta735a2abd734748aace06987632353f161e8faf5 (diff)
downloadmpv-1bc1cd2305c65521010a3fa221ac785ac30b8d2d.tar.bz2
mpv-1bc1cd2305c65521010a3fa221ac785ac30b8d2d.tar.xz
player: avoid stalling when starting a network stream
Starting a network stream could stall by executing uncacheable stream control requests (STREAM_CTRL_GET_LANG and STREAM_CTRL_GET_DVD_INFO). Being uncacheable means the player has to wait until the cache is done reading the current block of data. These requests can't be cached because they're too complicated, so the only way to avoid them is special casing the DVD and Bluray streams (which are the only things which need these requests), and not doing them in other cases. (This is kind of inelegant, but so is the rest of the DVD/BD code.)
-rw-r--r--player/loadfile.c9
-rw-r--r--stream/stream.h1
-rw-r--r--stream/stream_bluray.c1
3 files changed, 9 insertions, 2 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 2189bc4130..70cf2e9502 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -443,13 +443,16 @@ static struct track *add_stream_track(struct MPContext *mpctx,
track->preloaded = !!stream->sub->track;
// Needed for DVD and Blu-ray.
- if (!track->lang) {
+ struct stream *st = track->demuxer->stream;
+ if (!track->lang && (st->uncached_type == STREAMTYPE_BLURAY ||
+ st->uncached_type == STREAMTYPE_DVD))
+ {
struct stream_lang_req req = {
.type = track->type,
.id = map_id_from_demuxer(track->demuxer, track->type,
track->demuxer_id)
};
- stream_control(track->demuxer->stream, STREAM_CTRL_GET_LANG, &req);
+ stream_control(st, STREAM_CTRL_GET_LANG, &req);
if (req.name[0])
track->lang = talloc_strdup(track, req.name);
}
@@ -472,6 +475,8 @@ static void add_dvd_tracks(struct MPContext *mpctx)
struct demuxer *demuxer = mpctx->demuxer;
struct stream *stream = demuxer->stream;
struct stream_dvd_info_req info;
+ if (stream->uncached_type != STREAMTYPE_DVD)
+ return;
if (stream_control(stream, STREAM_CTRL_GET_DVD_INFO, &info) > 0) {
for (int n = 0; n < info.num_subs; n++) {
struct track *track = talloc_ptrtype(NULL, track);
diff --git a/stream/stream.h b/stream/stream.h
index 9cb227bfa8..0ef06b6b9b 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -35,6 +35,7 @@ enum streamtype {
STREAMTYPE_RADIO,
STREAMTYPE_DVB,
STREAMTYPE_DVD,
+ STREAMTYPE_BLURAY,
STREAMTYPE_PVR,
STREAMTYPE_TV,
STREAMTYPE_MF,
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index 56cbee42d1..d7a8d0b0cf 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -390,6 +390,7 @@ err_no_info:
b->current_angle = angle;
b->current_title = title;
+ s->type = STREAMTYPE_BLURAY;
s->end_pos = title_size;
s->sector_size = BLURAY_SECTOR_SIZE;
s->flags = MP_STREAM_SEEK;